Modify a message
Edit and update the content of an existing message using the OpenIM React Native SDK.
Modify the content of a previously sent message in a conversation:
Use this method to correct typos or append annotations. Permitted message types, sender permissions, and editing time windows are governed by server configuration policies.
const updatedMessage: MessageItem = {
...message,
textElem: {
...message.textElem,
content: editedText,
},
};
const modifiedMessage = await OpenIMSDK.modifyMessage({
conversationID,
message: updatedMessage,
});Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | string | Yes | Target conversation ID containing the message. |
message | MessageItem | Yes | Complete modified message object, retaining the original clientMsgID and core metadata. |
Return value
A resolved Promise returns the updated MessageItem confirmed by the server. Update the local message list by replacing the entry matching clientMsgID. If the modification window has expired or the sender lacks edit permissions, an error is returned.
Listen for message modifications
When a message is edited in a conversation, all clients receive an OnMessageModified notification. The event delivers the full updated MessageItem. Reconcile your UI by matching the message via clientMsgID.
const handleMessageModified = (message: MessageItem) => {
// Locate the message by message.clientMsgID and replace it in the active conversation view
};
// Register listener
OpenIMSDK.on(OpenIMEvent.OnMessageModified, handleMessageModified);
// Unregister listener on cleanup
OpenIMSDK.off(OpenIMEvent.OnMessageModified, handleMessageModified);Always unregister listeners using identical function references when unmounting components or signing out.
Was this page helpful?