Browse SDKs · iOS
Platform
SDKsiOS

Generate a conversation ID

Derive a conversation ID from a chat target with OpenIM iOS SDK.

Copy

Compute a deterministic conversation identifier string synchronously using getConversationIDBySessionType:sourceID:. Use this method to obtain conversation IDs locally without performing string concatenation or sending network requests.

Parameters

ParameterTypeRequiredDescription
sessionTypeOIMConversationTypeYesConversation category. Pass OIMConversationTypeC2C for direct chats or OIMConversationTypeGroup for group chats.
sourceIDNSString *YesPeer user ID for direct chats, or group ID for group chats.

Code example

NSString *conversationID = [[OIMManager manager]
    getConversationIDBySessionType:OIMConversationTypeC2C
                          sourceID:@"user_1002"];

if (conversationID.length > 0) {
    [self handleConversationID:conversationID];
}

Return value

The method synchronously returns a normalized NSString * representing the unique conversation identifier. If arguments are invalid, it may return nil or an empty string.

This method operates purely in-memory without initiating network requests, database transactions, or delegate notifications. It derives identifier strings only; to retrieve complete conversation metadata including unread counts and drafts, invoke Retrieve a conversation by chat target.