Browse SDKs · React Native
SDKsReact NativeEnterprise

Modify a message

OpenIM React Native SDK guide for modify a message.

Copy

Use modifyMessage() to modify an existing message in a conversation.

const updatedMessage = {
  ...message,
  textElem: {
    ...message.textElem,
    content: editedText,
  },
};

const modifiedMessage = await OpenIMSDK.modifyMessage({
  conversationID,
  message: updatedMessage,
});

Parameters

ParameterTypeRequiredDescription
conversationIDstringYesConversation containing the message.
messageMessageItemYesComplete modified message. Preserve its original clientMsgID and other required fields.

Return value

The call returns the server-confirmed MessageItem. You can replace the message with the same clientMsgID in your list. The server validates permitted message types, senders, and time limits.

Listen for message modification

When a message is modified, OnMessageModified is emitted with the modified MessageItem directly.

function handleMessageModified(message) {
  // ...
}

// Set the listener
OpenIMSDK.on(OpenIMEvent.OnMessageModified, handleMessageModified);

// Remove the listener
OpenIMSDK.off(OpenIMEvent.OnMessageModified, handleMessageModified);

Remove the listener when the component is destroyed, the account signs out, or the account changes.