Browse SDKs · iOS
Platform
SDKsiOSEnterprise

Create a conversation group

Create a conversation group with OpenIM iOS SDK.

Copy

Invoke Open_im_sdkCreateConversationGroup to create a custom conversation group for the signed-in user. A regular group requires a name; pass a conversationID to add an initial conversation into the group at creation time:

Parameters

ParameterTypeRequiredDescription
nameNSString *YesName of the conversation group.
orderNSNumber *NoSorting order index for group display.
exNSString *NoCustom extension string.
conversationIDNSString *NoID of a conversation to include immediately upon creation.
conversationGroupTypeNSNumber *NoGroup type (0 for a regular custom group, 1 for a rule-filtered group).

Code example

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

NSDictionary *request = @{
    @"name": @"Work",
    @"order": @100,
    @"conversationID": @"c2c_user1002",
    @"conversationGroupType": @0,
};

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 upsertConversationGroupJSON:data];
    }
    onFailure:^(NSInteger code, NSString * _Nullable message) {
        NSLog(@"CreateConversationGroup failed: %ld %@", (long)code, message);
    }];

Open_im_sdkCreateConversationGroup(callback, requestJSON);

Return value

The onSuccess callback delivers a JSON string in data representing the newly created group. Common fields include conversationGroupID, name, order, version, conversationGroupType, hidden, unreadCount, and conversationIDs.

State changes after the call

  1. Local state update: The client parses the JSON response and inserts or updates the group record using conversationGroupID as the unique key.
  2. Event notification: Multi-device synchronization or subsequent changes broadcast via the onConversationGroupAdded: listener callback.
  3. Re-query calibration: For comprehensive listener configuration and data structures, refer to Conversation groups overview.