Get conversation ID
Compute a stable conversation identifier from a target user or group identifier and session type.
When you only need to determine a stable conversationID without fetching the full conversation data object, compute it directly using the chat target identifier and session type. Supply the peer user ID for single chats or the group ID for group chats. Always invoke this SDK method rather than attempting to concatenate or format conversation IDs manually.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
sourceID | string | Yes | Target identifier: peer user ID for single chats, or group ID for group chats. |
sessionType | OpenIMSessionType | Yes | Use OpenIMSessionTypeSingle for single chats, or OpenIMSessionTypeWriteGroup for standard group chats. |
Code example
import {
OpenIMSessionTypeSingle,
getConversationIDBySessionType,
} from '@/uni_modules/unix-openim-sdk'
const conversationID = await getConversationIDBySessionType({
sourceID: targetUserID,
sessionType: OpenIMSessionTypeSingle,
})Return value
The Promise resolves with a string representing the unique, deterministic conversation identifier. Use this ID for conversation configuration, message history queries, read receipt operations, hiding, or deletion.
State changes after the call
This call computes the identifier deterministically from local and SDK parameters without making network requests or modifying local database state. It does not trigger conversation events.
Was this page helpful?