please select

Clear History Message

Feature Description

When messages in a conversation are cleared, all the messages in the conversation will be cleared both locally and from the cloud, but the conversation itself will not be deleted.
Note
1. When messages in a conversation are cleared, unreadCount will be set to 0, and the content of lastMessage will be cleared as well.
2. This API cannot be used to clear messages in a topic.
3. To delete a conversation when clearing messages in the conversation, use the deleteConversation API.

Clearing Messages

API
chat.clearHistoryMessage(conversationID);
Parameters
Name
Type
Description
conversationID
String
Conversation ID, in the format of:
C2C${userID} (for one-to-one chats)
GROUP{groupID} (for group chats)
Return values
Promise
Sample
// Clear one-to-one messages locally and from the cloud
let promise = chat.clearHistoryMessage('C2CExample');
promise.then(function(imResponse) {
// Messages cleared successfully
}).catch(function(imError){
console.warn('clearHistoryMessage error:', imError); // Message clearing failure information
});
// Clear group messages locally and from the cloud
let promise = chat.clearHistoryMessage('GROUPExample');
promise.then(function(imResponse) {
// Messages cleared successfully
}).catch(function(imError){
console.warn('clearHistoryMessage error:', imError); // Message clearing failure information
});