Browse SDKs · iOS
Platform
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, invoke revokeMessage:clientMsgID:onSuccess:onFailure: on OIMManager 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.

Parameters

ParameterTypeRequiredDescription
conversationIDNSString *YesTarget conversation identifier.
clientMsgIDNSString *YesClient message ID of the message to revoke.
onSuccessOIMSuccessCallbackYesSuccess callback confirming the revocation request completed.
onFailureOIMFailureCallbackYesFailure callback returning error code code and descriptive message message.

Code example

[[OIMManager manager] revokeMessage:conversationID
                        clientMsgID:clientMsgID
                          onSuccess:^(NSString * _Nullable data) {
    // Revocation succeeded; update message bubble to revoked state in local UI
    [self markMessageRevoked:clientMsgID conversationID:conversationID];
}
                          onFailure:^(NSInteger code, NSString * _Nullable message) {
    [self showRevokeError:code message:message ?: @"Failed to revoke the message"];
}];

Return value

The onSuccess callback confirms that the revocation request was processed by the server. The client merge key is clientMsgID (scoped to conversationID).

Receive revocation events

When another member or another logged-in device revokes a message, the SDK notifies the client via onRecvMessageRevoked: in OIMAdvancedMsgListener:

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

When using block callbacks on OIMCallbacker, the revokedInfo argument may be nil and must be validated before processing:

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

State changes after the call

  1. Permissions and validation: The server enforces permission checks, time window restrictions, and eligible message types for revocation. Do not mutate the UI to a revoked state if the call fails.
  2. Context resolution: Because OIMMessageRevokedInfo does not provide conversationID, locate the cached original message by clientMsgID, then combine its conversation with the event's sessionType to update the bubble display.
  3. Synchronization phases: The successful call, event arrival on remote devices, and reloading history are three distinct operational stages. For complete listener lifecycle details, see Receive messages.