Browse SDKs · iOS
SDKsiOS

Revoke a message

Revoke a message and synchronize its revoked state through the message listener.

Copy

When other conversation participants should see that a message was revoked, call revokeMessage:clientMsgID:onSuccess:onFailure: rather than substituting a regular deletion. Deletion affects visibility for the current account only; see Delete a message. To retain the message while changing its content, use Modify a message.

Revoke one message

Parameters

ParameterTypeRequiredDescription
conversationIDNSString *YesThe ID of the conversation containing the message.
clientMsgIDNSString *YesThe ID of the message to revoke.
[[OIMManager manager] revokeMessage:conversationID
                        clientMsgID:clientMsgID
                          onSuccess:^(NSString * _Nullable data) {
    [self markMessageRevoked:clientMsgID conversationID:conversationID];
}
                          onFailure:^(NSInteger code, NSString * _Nullable message) {
    [self showRevokeError:code message:message ?: @"Failed to revoke the message"];
}];

After success, the caller can immediately update the matching clientMsgID in the current list to a revoked state. OpenIMServer validates the permitted sender, time window, and message types. If the call fails, do not leave a local-only revoked state in the UI.

Result

A successful callback means that the current revocation request has completed; it does not mean that every client UI has already updated. Other clients merge the revocation event incrementally. After a connection recovery or new login, message synchronization and history queries reconcile the state again.

Receive revocation events

This page owns onRecvMessageRevoked:. Implement it on the application's existing OIMAdvancedMsgListener:

- (void)onRecvMessageRevoked:(OIMMessageRevokedInfo *)revokedInfo {
    [self markMessageRevokedByClientMsgID:revokedInfo.clientMsgID
                              sessionType:revokedInfo.sessionType];
}

When using the closure form on OIMCallbacker, the OIMRevokedCallback argument is nullable and must be checked first:

OIMRevokedCallback handleMessageRevoked =
    ^(OIMMessageRevokedInfo * _Nullable revokedInfo) {
    if (revokedInfo == nil) {
        return;
    }
    [self markMessageRevokedByClientMsgID:revokedInfo.clientMsgID
                              sessionType:revokedInfo.sessionType];
};

OIMMessageRevokedInfo does not contain conversationID. Locate the cached original message by clientMsgID, then combine its conversation with the event's sessionType to update the revoked state. Do not remove a message by array position. Retain the listener strongly, register it with addAdvancedMsgListener:, and remove the same instance with removeAdvancedMsgListener:. See Receive messages for the complete setup.

The successful call, event arrival on another client, and reloading history are three separate stages.