SDKsReact NativeEnterprise
Delete messages in a batch
OpenIM React Native SDK guide for delete messages in a batch.
Use deleteMessages() to delete multiple messages from one conversation.
await OpenIMSDK.deleteMessages({
conversationID,
clientMsgIDs,
isSync: true,
});Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | string | Yes | Conversation containing the messages. |
clientMsgIDs | string[] | Yes | IDs of the messages to delete; all must belong to the same conversation. |
isSync | boolean | Yes | Whether to synchronize deletion to the other participant. true deletes the messages for both participants; false deletes them only for the current account. In either case, the deletion is synchronized to the current account's other devices. |
After the call completes, the deletion request has completed. With isSync: true, the other participant also deletes the messages; with false, only the current account deletes them.
Listen for message deletion
When messages are deleted, OnMsgDeleted is emitted with the deleted MessageItem. Use clientMsgID to update the corresponding message list.
function handleMessageDeleted(message) {
// ...
}
// Set the listener
OpenIMSDK.on(OpenIMEvent.OnMsgDeleted, handleMessageDeleted);
// Remove the listener
OpenIMSDK.off(OpenIMEvent.OnMsgDeleted, handleMessageDeleted);Remove the listener when the component is destroyed, the account signs out, or the account changes.
Was this page helpful?