Browse SDKs · iOS
SDKsiOS

Retrieve a conversation by chat target

Retrieve a conversation for a user or group with OpenIM iOS SDK.

Copy

When opening a chat page from a user or group profile, retrieve its OIMConversationInfo by the chat target. For a one-to-one chat, pass the other user's ID and OIMConversationTypeC2C. For a group chat, pass the group ID and OIMConversationTypeGroup.

[[OIMManager manager] getOneConversationWithSessionType:OIMConversationTypeC2C
                                              sourceID:targetUserID
                                              onSuccess:^(OIMConversationInfo *conversation) {
                                                  [chatRouter openConversation:conversation];
                                              }
                                              onFailure:nil];

Even if the users have not exchanged messages, do not construct conversationID or the model yourself. The success callback returns a complete conversation snapshot. The query itself does not trigger a delegate.