Revoke a message
Recall a previously sent message within the permitted time window using the OpenIM React Native SDK.
Recall a previously sent message from a conversation:
Upon successful revocation, clients in the conversation update the message bubble to display a revocation placeholder (e.g., "Message was recalled").
await OpenIMSDK.revokeMessage({
conversationID,
clientMsgID,
});Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | string | Yes | Target conversation ID. |
clientMsgID | string | Yes | Client message ID of the message to revoke. |
Return value
A resolved Promise confirms that the revocation request was accepted and processed by the server. Revocation time constraints (e.g. within 2 minutes) and role permissions are validated by server policy; exceeding the limit returns an error.
Listen for message revocations
When a message is recalled, all clients in the conversation receive the OnNewRecvMessageRevoked event. The callback payload contains a RevokedInfo object. Locate the target message by clientMsgID and update its display state to a recalled notice.
interface RevokedInfo {
clientMsgID: string;
revokerID: string;
revokerRole: number;
revokerNickname: string;
sessionType: number;
}
const handleMessageRevoked = (revokedInfo: RevokedInfo) => {
// Locate the message by revokedInfo.clientMsgID and update its status to revoked
};
// Register listener
OpenIMSDK.on(OpenIMEvent.OnNewRecvMessageRevoked, handleMessageRevoked);
// Unregister listener on cleanup
OpenIMSDK.off(OpenIMEvent.OnNewRecvMessageRevoked, handleMessageRevoked);To remove a message strictly from the local device without alerting the counterparty, use Delete local message.
Was this page helpful?