SDKsHarmonyOSEnterprise
Retrieve conversation by target
Look up an individual conversation record by target user ID or group ID.
When navigating into a chat interface from a user profile, contact card, or group information view, query the corresponding conversation record by its target entity:
Code example
import sdk, { GetOneConversationReq, GetOneConversationResp, SessionType } from '@openimsdk/imsdk';
const request: GetOneConversationReq = {
sourceID: targetUserID,
sessionType: SessionType.Single,
};
const response: GetOneConversationResp = await sdk.getOneConversation(request);
openChatPage(response.conversation);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
sourceID | string | Yes | Target entity identifier: the peer userID for direct chats, or groupID for group chats. |
sessionType | SessionType | Yes | SessionType.Single for direct chats or SessionType.WriteGroup for group chats. |
Return value
Returns a Promise that resolves to a GetOneConversationResp object:
| Property | Type | Description |
|---|---|---|
conversation | IMConversation | The matched conversation record. |
State changes after the call
Resolving the Promise yields the current snapshot of the target conversation without triggering events. Subsequent unread badge changes, drafts, and message summaries are delivered through the conversation events documented in Retrieve conversation list.
Was this page helpful?