Revoke a message
Revoke a message and synchronize its revoked state through the message listener.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | NSString * | Yes | Target conversation identifier. |
clientMsgID | NSString * | Yes | Client message ID of the message to revoke. |
onSuccess | OIMSuccessCallback | Yes | Success callback confirming the revocation request completed. |
onFailure | OIMFailureCallback | Yes | Failure 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
- 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.
- Context resolution: Because
OIMMessageRevokedInfodoes not provideconversationID, locate the cached original message byclientMsgID, then combine its conversation with the event'ssessionTypeto update the bubble display. - 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.
Was this page helpful?