Browse SDKs · Android
Platform
SDKsAndroid

Revoke a message

Revoke a sent message and handle revocation notifications received by other clients.

Copy

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

ParameterTypeRequiredDescription
baseOnBase<String>YesCallback handler for the asynchronous request.
conversationIDStringYesGlobally unique ID of the conversation containing the message.
clientMsgIDStringYesClient 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

  1. Callback confirmation: The onSuccess callback indicates that the server processed the revocation.
  2. Asynchronous event delivery: Receiving clients receive onRecvMessageRevokedV2 with RevokedInfo. Update message state in-place using clientMsgID.
  3. 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.