Modify a message
Modify supported message content and handle modification events received by other clients.
Edit and update the content of an already-sent message online. Typically, you clone the original Message object, modify editable fields (such as text content in textElem), and submit the updated object while retaining all original identifiers (clientMsgID, serverMsgID).
Code example
// Clone or copy original message and update text content
Message modifiedMessage = originalMessage;
modifiedMessage.getTextElem().setContent("This is the updated message content.");
OpenIMClient.getInstance().messageManager.modifyMessage(
new OnBase<String>() {
@Override
public void onSuccess(String data) {
// Message modified successfully
}
@Override
public void onError(int code, String error) {
// Failed to modify message
}
},
modifiedMessage
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<String> | Yes | Callback handler for the asynchronous request. |
message | Message | Yes | The updated Message object. Must retain original identifiers including clientMsgID, serverMsgID, and conversation bindings. |
Return value
Upon success, data in onSuccess returns a confirmation message.
Handling message modification events
After a message is modified, other online clients in the conversation receive the updated Message through OnAdvanceMsgListener.onMessageModified:
@Override
public void onMessageModified(Message message) {
// message contains updated content; refresh UI by message.getClientMsgID()
}Upon receiving onMessageModified, match the message by clientMsgID to refresh the text bubble in-place and display an "edited" status indicator.
State changes after the call
- Callback confirmation: The
onSuccesscallback indicates that the modification was saved on the server. Update the local UI model with the new content. - Asynchronous event delivery: Peer clients receive
onMessageModifiedwith the complete updatedMessage. Merge in-place usingclientMsgID. - Re-query calibration: If message content falls out of sync, reload via Load older messages.
For complete listener registration and lifecycle management, see Receive messages.
Was this page helpful?