Revoke a message
Revoke a sent message and handle revocation notifications received by other clients.
Revoking a message causes all conversation members to display the original message in a revoked state. OpenIM Server validates the message status, operator permissions, and the allowed revocation time window.
If you only need to remove a message from the current account's view, use Delete saved messages instead of revoking it. To change the content of an existing message, use Modify a message.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | String | Yes | ID of the conversation containing the message. Flutter's Message model does not contain this field. |
clientMsgID | String | Yes | Target client message ID to revoke. |
Code example
final clientMsgID = message.clientMsgID;
if (clientMsgID == null || clientMsgID.isEmpty) {
throw StateError('Message has no clientMsgID');
}
await OpenIM.iMManager.messageManager.revokeMessage(
conversationID: conversationID,
clientMsgID: clientMsgID,
);Flutter's Message model does not contain a conversationID field; the call site must supply the conversationID maintained by the current conversation context. If you only hold a message object from an event, resolve the route as shown in Receive messages and obtain the conversation ID using the conversation ID helper.
Return value
Future completion indicates that the server has processed the revocation request. The active client should immediately update the matching message bubble in place to a "revoked" state using the composite key conversationID:clientMsgID.
Future completion does not guarantee that event notifications have arrived at all clients. If server-side validation indicates that the message does not exist or the revocation time limit has expired, the call throws an error. Show the error to the user and keep the original message visible; do not mark the message as revoked locally when the request fails.
State changes after the call
Message revocation events are handled through the onNewRecvMessageRevoked callback in OnAdvancedMsgListener. The callback provides a RevokedInfo payload. Update the local message bubble in place using the composite key conversationID:clientMsgID:
void handleMessageRevoked(RevokedInfo info) {
final clientMsgID = info.clientMsgID;
if (clientMsgID == null || clientMsgID.isEmpty) return;
final conversationID = findConversationIDByClientMsgID(clientMsgID);
if (conversationID == null) return;
markMessageRevoked(conversationID, clientMsgID, info);
}We recommend transforming the revoked message into an in-place tombstone notice (such as "You revoked a message" or "A message was revoked") rather than deleting the item entirely from the UI list. This maintains chat timeline continuity and prevents UI layout jumps when subsequently fetching historical message batches. Register this handler in the application's single OnAdvancedMsgListener; for global configuration, see Events overview.
Related guides
Was this page helpful?