Browse SDKs · Android
Platform
SDKsAndroid

Generate a conversation ID

Compute a conversation ID locally from the chat target and session type.

Copy

Compute a conversationID synchronously on the client from the target ID and session type without executing network queries.

Code example

String conversationID = OpenIMClient.getInstance().conversationManager
    .getConversationIDBySessionType(
        sourceId,
        ConversationType.SINGLE_CHAT
    );

Parameters

ParameterTypeRequiredDescription
sourceIdStringYesTarget identifier. Pass the peer userID for direct chats or the groupID for group chats.
sessionTypeintYesConversation type: ConversationType.SINGLE_CHAT for direct chats; ConversationType.GROUP_CHAT or ConversationType.SUPER_GROUP_CHAT for group chats.

Return value

Returns the computed conversationID string synchronously. This method is a pure local calculation that performs no network requests. To retrieve conversation metadata such as unread count, draft text, or latest message, call Get a conversation by target.