Browse SDKs · uni-app / uni-app x
SDKsuni-app

Send an uploaded media message

OpenIM uni-app / uni-app x SDK guide for Send an uploaded media message.

Copy

Use sendMessageNotOss() when an image, audio, video, or file was already uploaded by your business service and the message contains its URL. This avoids the SDK upload phase.

Parameters

ParameterTypeRequiredDescription
recvIDstringConditionalReceiver user ID for a single chat; otherwise pass an empty string.
groupIDstringConditionalGroup ID for a group chat; otherwise pass an empty string.
messageOpenIMMessageItemYesOutgoing message returned by a by-URL create API with complete remote resource metadata.
offlinePushInfoOpenIMOfflinePush or nullNoOffline-push title, description, and platform settings.
isOnlineOnlyboolean or nullNoDeliver only to online clients; such a message is not stored in local history.
import { sendMessageNotOss } from '@/uni_modules/unix-openim-sdk'

const sentMessage = await sendMessageNotOss({
  recvID: receiverUserID,
  groupID: '',
  message: urlMessage,
})

The URL, size, type, dimensions, and duration must come from the real upload result. The Promise resolves directly to the server-confirmed OpenIMMessageItem; merge it by clientMsgID.

This method does not upload resources and must not receive a message that only contains a local file path, or recipients may be unable to access it. Send local-file messages with sendMessage().