Browse SDKs · WASM
SDKsWASM

Insert a local one-to-one message

Insert a local one-to-one message with the WASM SDK.

Copy

Parameters

ParameterTypeRequiredDescription
messageMessageItemYesComplete message object to write to the local database.
recvIDstringYesUser ID of the one-to-one recipient.
sendIDstringYesUser ID of the message sender.
const { data: message } = await openimsdk.createTextMessage('Local notice');
await openimsdk.insertSingleMessageToLocalStorage({
  message,
  recvID: targetUserID,
  sendID: currentUserID,
});

When the Promise resolves, the message has been written only to the current device's local database. It is not sent and does not trigger a new-message event. createTextMessage() only prepares the parameter; its documentation belongs to Create a text message.