Revoke a message
Revoke a sent message and handle revocation notifications received by other clients.
Recall a previously sent message within the allowed revocation time window. Upon successful invocation, the message in the conversation is marked as revoked, and peer clients receive an asynchronous event to replace the original message body with a revocation notice.
Code example
String conversationID = "si_user_a_user_b";
String clientMsgID = "msg_001";
OpenIMClient.getInstance().messageManager.revokeMessageV2(
new OnBase<String>() {
@Override
public void onSuccess(String data) {
// Revocation request processed successfully
}
@Override
public void onError(int code, String error) {
// Failed to revoke message (e.g. exceeded allowed time limit)
}
},
conversationID,
clientMsgID
);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<String> | Yes | Callback handler for the asynchronous request. |
conversationID | String | Yes | Globally unique ID of the conversation containing the message. |
clientMsgID | String | Yes | Client message ID of the message to revoke. |
Return value
Upon success, data in onSuccess returns a confirmation message.
Handling message revocation events
Clients across the conversation receive revocation notices through OnAdvanceMsgListener.onRecvMessageRevokedV2:
@Override
public void onRecvMessageRevokedV2(RevokedInfo info) {
// Find the original message using info.getClientMsgID()
// Update its state to revoked and display revoker name (info.getRevokerNickname())
}When receiving onRecvMessageRevokedV2, match the targeted message using clientMsgID and render a revocation placeholder (e.g., "Alex revoked a message") rather than deleting the message row from the list.
State changes after the call
- Callback confirmation: The
onSuccesscallback indicates that the server processed the revocation. - Asynchronous event delivery: Receiving clients receive
onRecvMessageRevokedV2withRevokedInfo. Update message state in-place usingclientMsgID. - Re-query calibration: If message states fall out of sync, reload message history via Load older messages.
For complete listener registration and lifecycle management, see Receive messages.
Was this page helpful?