Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Conversation overview

Understand the relationship between conversation records, target entities, conversation IDs, and list synchronization.

Copy

A conversation represents the client-side chat record maintained by the signed-in user for a specific one-to-one peer or group. The IMConversation object encapsulates the target entity, display name, latest message summary, unread badge count, draft content, and user-specific conversation preferences.

IdentifierDescription
conversationIDStable conversation identifier used across message retrieval, read receipts, and conversation preferences.
userIDTarget peer user ID for one-to-one chats.
groupIDTarget group ID for group chats.
sourceIDTarget entity identifier when querying by target: peer user ID for direct chats, group ID for group chats.

Use SessionType.Single for direct chats and SessionType.WriteGroup for group chats. Do not manually format or concatenate string patterns to generate a conversationID; obtain it from the SDK.

Initialize the conversation list by fetching a snapshot with Retrieve conversation list, then apply incremental updates received from new and changed conversation events. Merge updates into your client store using conversationID. After reconnection, account synchronization, or when updates may have been missed, re-query the list to reconcile state.

Conversation settings—such as pinning, flags, remarks, drafts, message receive options, burn-after-reading timers, and server destruction policies—operate independently. Each capability is documented under its specific operation guide to prevent accidental field overwrites.