SDKsReact Native
Delete all messages from a user in a group chat
OpenIM React Native SDK guide for delete all messages from a user in a group chat.
Use deleteUserAllMessagesInConv() to delete all messages from a specified user in a group conversation.
await OpenIMSDK.deleteUserAllMessagesInConv({
conversationID,
userID,
});Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | string | Yes | Target group conversation ID. |
userID | string | Yes | User whose messages are deleted. |
This is a group-management operation. After it completes, the deletion request has completed; the server validates permissions.
Listen for deletion of a user's messages
After deletion, OnDeleteUserAllMsgsInConv is emitted with conversationID and userID. Use them to remove that user's messages from the target conversation.
function handleUserMessagesDeleted(data) {
// ...
}
// Set the listener
OpenIMSDK.on(
OpenIMEvent.OnDeleteUserAllMsgsInConv,
handleUserMessagesDeleted,
);
// Remove the listener
OpenIMSDK.off(
OpenIMEvent.OnDeleteUserAllMsgsInConv,
handleUserMessagesDeleted,
);Remove the listener when the component is destroyed, the account signs out, or the account changes.
Was this page helpful?