please select
  • UIKit
  • SDK
  • Server APIs
Chat/
SDK/
Web/
Message/
SDK
  • Install Chat SDK
  • Initialize Chat SDK
  • Login and Logout
  • Client APIs
  • Changelog
  • Message
    • Overview
    • Send a Message
    • Receive a Message
    • Historical Message
    • Forward Messages
    • Modify a Message
    • Delete Messages
    • Clear History Message
    • Recall a Message
    • Send an Online Message
    • Message Read Receipt
    • Query Messages
    • Targeted Group Message
    • Do not Notify
    • Key-Value Extensions
    • Translation
  • Conversation
    • Overview
    • Conversation List
    • Get Conversations
    • Unread Count
    • Pin Conversations
    • Delete Conversations
    • Mark
    • Conversation Group
  • Group
    • Overview
    • Group Management
    • Group Profile
    • Group Member Management
    • Group Member Profile
    • Custom Group Attribute
    • Group Counter
  • Community Topic
    • Community Management
  • User Profile and Relationship Chain
    • User Profile
    • User Status
    • Friend Management
    • Friend Group
    • Block List
  • Guideline for Beginners
  • Console Guide
    • Creating and Upgrading an Application
    • Basic Configuration
    • Feature Configuration
    • Account Management
    • Group Management
    • Webhook Configuration
  • Product Introduction
    • Message Management
      • One-to-One Message
      • Message Storage
      • Offline Push
      • Group Message
      • Message Formats
    • Account System
      • Login Authentication
      • Online Status Management
    • Group Related
      • Group System
      • Group Management
    • User Profile and Relationship Chain
      • Profile Management
      • Relationship Chain Management
  • Purchase Guide
    • Billing Overview
    • Pricing
  • Error Codes

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
});