Browse SDKs · React Native
Platform
SDKsReact Native

Insert local single message

Insert a message directly into local storage for a one-to-one chat without sending over the network using the OpenIM React Native SDK.

Copy

Write a one-to-one message directly into local device database storage:

This method saves the message exclusively in the local client database without transmitting network packets to the server or conversation counterparty. It is ideal for inserting local greeting prompts, service guidelines, or temporary UI placeholders.

const localMessage = await OpenIMSDK.insertSingleMessageToLocalStorage({
  message,
  recvID,
  sendID,
});

Parameters

ParameterTypeRequiredDescription
messageMessageItemYesComplete message object to store locally, typically constructed via message creation methods.
recvIDstringYesRecipient user ID for the one-to-one chat.
sendIDstringYesSender user ID, which can be the current user or a virtual system user ID.

Return value

A resolved Promise returns the MessageItem written to the local database. The message is indexed locally by clientMsgID. To dispatch messages over the network to the counterparty, use Send message.