Generate a conversation ID
Derive a conversation ID from a chat target with OpenIM iOS SDK.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
sessionType | OIMConversationType | Yes | Conversation category. Pass OIMConversationTypeC2C for direct chats or OIMConversationTypeGroup for group chats. |
sourceID | NSString * | Yes | Peer 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.
Was this page helpful?