Delete Conversations
Feature Description
If a user doesn't want to view the historical one-to-one or group messages after deleting a friend or leaving a group, the user can choose to delete the conversation.
Deleting a Conversation
Note:
1. When deleting a conversation, the default behavior is to clear the conversation history messages. Please be cautious before proceeding. If you need to retain the conversation history messages, please set
clearHistoryMessage
to false
.2. Multi-client sync is disabled for conversation deletion by default. To enable it, log in to the Chat Console, select Application Configuration > Feature Configuration > Login and Message > Multi-client Synchronization Settings, and enable Sync Conversation Deletion Across Clients.
3. It supports for bulk deletion of conversations (up to 100 conversations at a time), with the option to choose whether to clear the history messages.
4. In scenarios such as members leaving the group, the group owner dissolving the group, or members being kicked out of the group, if the user's login state has not expired, the corresponding group conversation will still be retained in the local conversation list. At this time, users can view the cached historical messages, but they cannot send messages.
API
chat.deleteConversation(options);
Parameter
Name | Type | Description |
options | String | Object | If the options parameter is of the String type, it's valid values as blow: C2C${userID} (for a one-to-one chat)GROUP{groupID} (for a group chat)@TIM#SYSTEM (for a system notification conversation) |
Returned value
Promise
Sample
// delete the specified conversation and clear chat historylet promise = chat.deleteConversation('C2CExample');promise.then(function(imResponse) {// Deleted the conversation successfullyconst { conversationID } = imResponse.data;// ID of the deleted conversation}).catch(function(imError) {console.warn('deleteConversation error:', imError); // Failed to delete the conversation});
// delete the specified conversation and not clear chat historylet promise = chat.deleteConversation({conversationIDList: ['C2CExample'], clearHistoryMessage: false});promise.then(function(imResponse) {// Deleted the conversation successfullyconst { conversationIDList } = imResponse.data; // ID of the deleted conversation}).catch(function(imError) {console.warn('deleteConversation error:', imError); // Failed to delete the conversation});
// delete multiple conversations and clear chat historylet promise = chat.deleteConversation({conversationIDList: ['C2CExample', 'GROUPExample']});promise.then(function(imResponse) {const { conversationIDList } = imResponse.data; // ID list of the deleted conversations}).catch(function(imError) {console.warn('deleteConversation error:', imError); // Failed to delete the conversation});
// delete multiple conversations and clear chat historylet promise = chat.deleteConversation({conversationIDList: ['C2CExample', 'GROUPExample'],clearHistoryMessage: false});promise.then(function(imResponse) {const { conversationIDList } = imResponse.data; // ID list of the deleted conversations}).catch(function(imError) {console.warn('deleteConversation error:', imError); // Failed to delete the conversation});