Retrieve the conversation list
Retrieve the current user’s conversation list with pagination and merge subsequent changes through delegates.
The conversation list belongs to the authenticated user. Each OIMConversationInfo object contains conversation identifiers, unread counts, latest messages, pinned statuses, and draft texts. Always query conversations using paginated APIs rather than unpaginated complete fetch methods.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
offset | NSInteger | Yes | Starting offset index. Pass 0 for the first page. |
count | NSInteger | Yes | Number of conversation items to fetch per page. |
Code example
NSInteger pageSize = 50;
[[OIMManager manager] getConversationListSplitWithOffset:0
count:pageSize
onSuccess:^(NSArray<OIMConversationInfo *> *items) {
[conversationStore mergeByConversationID:items ?: @[]];
}
onFailure:^(NSInteger code, NSString *message) {
NSLog(@"getConversationListSplit failed: %ld %@", (long)code, message);
}];Conversation state merges using conversationID as the unique entity key.
Return value
The onSuccess callback returns an NSArray<OIMConversationInfo *> * containing conversation objects for the requested page. An empty array or an array with fewer than count items indicates that the end of the conversation list has been reached.
When fetching additional pages, increment offset by the count of successfully retrieved items and merge results into local stores idempotently using conversationID. When the user triggers a pull-to-refresh action, reset the pagination cursor to 0 and re-fetch the initial page.
Synchronize conversation updates
Paginated queries establish an initial conversation snapshot, while the OIMConversationListener protocol handles real-time updates for newly created conversations or mutated properties. Register the listener after SDK initialization. Retain the listener instance strongly, as OIMCallbacker maintains only weak references to delegates.
@interface ConversationListSync : NSObject <OIMConversationListener>
@end
@interface ConversationListController ()
@property (nonatomic, strong) ConversationListSync *conversationListSync;
@end
@implementation ConversationListSync
- (void)onNewConversation:(NSArray<OIMConversationInfo *> *)items {
[conversationStore mergeByConversationID:items];
}
- (void)onConversationChanged:(NSArray<OIMConversationInfo *> *)items {
[conversationStore mergeByConversationID:items];
}
@end
ConversationListSync *sync = [ConversationListSync new];
self.conversationListSync = sync;
[[OIMManager callbacker] addConversationListener:sync];
// Upon account logout or view controller deallocation:
[[OIMManager callbacker] removeConversationListener:self.conversationListSync];
self.conversationListSync = nil;Merge all incoming updates idempotently by conversationID. Account-wide unread counts are observed via Maintain the total unread count, and typing status indicators are managed via Report typing status.
Do not substitute the joined group list for the conversation list: a user may belong to a group that has not yet generated messages, or may retain historical conversation state after leaving a group.
Was this page helpful?