SDKsHarmonyOSEnterprise
Clear conversation messages
Purge all messages in a conversation while retaining the conversation entry.
Clear chat history for a specific conversation while preserving its presence in the conversation list:
Code example
import sdk, { ClearConversationAndDeleteAllMsgReq } from '@openimsdk/imsdk';
const request: ClearConversationAndDeleteAllMsgReq = {
conversationID: conversationID,
};
await sdk.clearConversationAndDeleteAllMsg(request);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | string | Yes | Target conversation identifier. |
Return value
Returns a Promise that resolves to void when messages are purged.
State changes after the call
Resolving the Promise purges messages locally. The conversation entry itself remains in the conversation list, and the SDK triggers EventOnConversationChanged to reset its latest message snippet, timestamp, and unread count. Correlate and update your conversation view using conversationID, as detailed in Retrieve conversation list. To remove the conversation entry together with its messages, see Delete conversation and messages.
Was this page helpful?