Browse SDKs · uni-app / uni-app x
Platform
SDKsuni-app / uni-app xIncludes Enterprise features

Conversation overview

Understand conversation records, chat targets, conversation IDs, and list synchronization workflows.

Copy

In the OpenIM SDK, a conversation represents the client-side chat session state maintained by the currently authenticated user for a direct single chat or group chat. Each OpenIMConversationItem record preserves unread counts, the latest message summary, pinned status, draft text, notification options, and message lifecycle policies.

A conversation record uses distinct identifiers from its chat target: conversationID identifies a specific conversation session for the authenticated user, whereas a single chat target is identified by the peer userID, and a group chat target is identified by groupID. A group chat UI typically needs groupID to access group profile and member capabilities, while using conversationID to manage conversation settings, unread counts, and message history.

Conversation identifiers

When retrieving a conversation or generating its identifier by target, pass the peer user ID as sourceID with OpenIMSessionTypeSingle for single chats, or pass the group ID as sourceID with OpenIMSessionTypeWriteGroup for group chats. Never manually concatenate or forge conversation ID strings in your application code.

IdentifierPurpose
conversationIDThe conversation record ID for the authenticated account, used for conversation settings, message history, and unread state.
userIDThe user ID of the peer user in a single chat.
groupIDThe group ID corresponding to a group chat, also used as the target identifier for group APIs.
sourceIDThe target identifier passed when querying by session type: userID for single chats, and groupID for group chats.

Conversation record responsibilities

The fields in OpenIMConversationItem serve several key responsibilities:

ResponsibilityRelevant fieldsDescription
Identity and typeconversationID, conversationType, userID, groupIDIdentify the conversation session and associate it with the concrete chat target.
List presentationshowName, faceURL, latestMsg, latestMsgSendTimeRender conversation title, avatar, and latest message snippet.
Unread and notificationsunreadCount, groupAtType, recvMsgOptDisplay unread message counts, group @ mention indicators, and message notification modes.
Local organizationisPinned, draftText, draftTextTime, isMarked Commercial, remark CommercialMaintain pinned position, custom markers, alias remarks, and locally saved draft text.
Message policiesisPrivateChat Commercial, burnDuration Commercial, isMsgDestruct Commercial, msgDestructTime CommercialControl self-destructing private chat duration and periodic server-side message cleanup.
Sync boundariesminSeq, maxSeq, updateUnreadCountTimeRecord message synchronization checkpoints and unread calculation timestamps.
Business extensionsex, attachedInfoStore custom application metadata and internal SDK extension payloads.

Querying and synchronization

Queries obtain a point-in-time local snapshot, while event callbacks deliver subsequent incremental updates. A successful mutation Promise resolution, event arrival, and a re-query snapshot represent three distinct lifecycle stages. Always merge incoming state updates using conversationID as the primary key, and re-query the latest conversation snapshot whenever event continuity may have been interrupted.