SDKsWASM
Send a message
Send a pending message object with the WASM SDK.
sendMessage() sends a MessageItem returned by a message creation API. For a one-to-one chat, set only recvID; for a group chat, set only groupID.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
recvID | string | Conditional | Recipient's user ID for a one-to-one chat. Pass an empty string for a group chat. |
groupID | string | Conditional | Target group ID for a group chat. Pass an empty string for a one-to-one chat. |
message | MessageItem | Yes | Pending message object to send. |
offlinePushInfo | OfflinePush | No | Offline push configuration. |
isOnlineOnly | boolean | No | Whether to deliver only to online clients. Online-only messages are not stored in local history. |
const { data: sentMessage } = await openimsdk.sendMessage({
recvID: receiverUserID,
groupID: '',
message,
});When the Promise resolves, data is the server-confirmed MessageItem. On the sending client, replace the local pending item by clientMsgID with the returned object. For common and content-specific fields, see Message overview.
Other clients receive the message through new-message events. Promise completion, arrival of the receiving event, and reconciliation through a history query are separate stages.
If the resource has already been uploaded by your application and stored in a URL-based message, use sendMessageNotOss().
Was this page helpful?