Revoke message
Recall an already sent message and synchronize its recalled state across participants.
Use this operation when conversation members need to see a recalled message notice, rather than silently deleting records locally or in batch.
Code example
import sdk, {
EventOnNewRecvMessageRevokedData,
OpenIMSDKEvent,
RevokeMessageReq,
} from '@openimsdk/imsdk';
const request: RevokeMessageReq = {
conversationID: conversationID,
clientMsgID: message.clientMsgID,
};
await sdk.revokeMessage(request);
const handleMessageRevoked = (data: EventOnNewRecvMessageRevokedData): void => {
markMessageRevoked(data.revoked.clientMsgID, data.revoked);
};
const unsubscribeMessageRevoked = sdk.on(
OpenIMSDKEvent.EventOnNewRecvMessageRevoked,
handleMessageRevoked,
);
export function removeMessageRevokedListener(): void {
unsubscribeMessageRevoked();
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | string | Yes | Target conversation identifier. |
clientMsgID | string | Yes | Client message identifier of the message to revoke. |
Return value
Returns a Promise that resolves to void upon server acceptance.
State changes after the call
Revocation permissions, eligible time windows, and revocable message types are verified by OpenIMServer. Resolving the Promise confirms request acceptance on the server without implying all peer clients have re-rendered. When the revocation event arrives, locate the item by clientMsgID and render a recalled message notification instead of removing the row entirely from the timeline. Remove the listener during logout or when disposing of the message state layer.
Was this page helpful?