Browse SDKs · iOS
Platform
SDKsiOSEnterprise

Retrieve conversations in a group

Retrieve a conversation group and its conversations by page with Open_im_sdkGetConversationGroupInfoWithConversations.

Copy

Invoke Open_im_sdkGetConversationGroupInfoWithConversations to retrieve detailed information for a specified conversation group and its contained conversations with pagination:

Parameters

ParameterTypeRequiredDescription
conversationGroupIDNSString *YesTarget conversation group ID.
pagination.pageNumberNSIntegerYesPage index, starting from 1.
pagination.showNumberNSIntegerYesPage size (number of conversations per page).

Code example

#import <OpenIMSDK/CallbackProxy.h>
@import OpenIMCore;

NSDictionary *request = @{
    @"conversationGroupID": @"group_work_101",
    @"pagination": @{ @"pageNumber": @1, @"showNumber": @20 },
};

NSData *requestData = [NSJSONSerialization dataWithJSONObject:request options:0 error:nil];
NSString *requestJSON = [[NSString alloc] initWithData:requestData
                                              encoding:NSUTF8StringEncoding];

CallbackProxy *callback = [[CallbackProxy alloc]
    initWithOnSuccess:^(NSString * _Nullable data) {
        if (data == nil) {
            return;
        }
        [self handleGroupConversationsPageJSON:data];
    }
    onFailure:^(NSInteger code, NSString * _Nullable message) {
        NSLog(@"GetConversationGroupInfoWithConversations failed: %ld %@", (long)code, message);
    }];

Open_im_sdkGetConversationGroupInfoWithConversations(callback, requestJSON);

Return value

The onSuccess callback delivers a JSON string in data containing group (group metadata), conversationElems (conversation objects for the requested page), and isEnd (boolean indicating whether the end of the list has been reached).

State changes after the call

  1. Snapshot query: This method queries a point-in-time snapshot and does not trigger listener callbacks.
  2. Pagination state: Use isEnd to determine whether more pages should be loaded.
  3. Event notification: Changes to group membership broadcast through onConversationGroupMemberAdded: and onConversationGroupMemberDeleted:. For listener handling, refer to Conversation groups overview.