please select

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. 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.
2. 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.
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 history
let promise = chat.deleteConversation('C2CExample');
promise.then(function(imResponse) {
// Deleted the conversation successfully
const { 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 history
let promise = chat.deleteConversation({conversationIDList: ['C2CExample'], clearHistoryMessage: false});
promise.then(function(imResponse) {
// Deleted the conversation successfully
const { 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 history
let 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 history
let 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
});