Browse SDKs · iOS
SDKsiOSEnterprise

Create a conversation group

Create a conversation group with Open_im_sdkCreateConversationGroup.

Copy

Open_im_sdkCreateConversationGroup creates a conversation group for the current user from a JSON req. A regular group requires at least a name. To add one conversation at creation time, also provide its conversationID.

Parameters

FieldRequiredDescription
nameYesThe group name.
orderNoThe ordering value. Define one sorting direction consistently across the product.
exNoAn application-defined extension string.
conversationIDNoA conversation to add to the group immediately after creation.
conversationGroupTypeNo0 for a regular group or 1 for a filtered group.
#import <OpenIMSDK/CallbackProxy.h>
@import OpenIMCore;

NSDictionary *request = @{
    @"name": @"Work",
    @"order": @100,
    @"conversationID": conversationID,
    @"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) {
        [self showConversationGroupError:code message:message ?: @"Failed to create the conversation group"];
    }];

Pass callback and requestJSON to Open_im_sdkCreateConversationGroup.

Result

The success callback's data is a JSON group object. Common fields include conversationGroupID, name, order, version, conversationGroupType, hidden, unreadCount, and conversationIDs.

Other signed-in clients or later synchronization may receive onConversationGroupAdded:. For the complete listener implementation, see Conversation groups overview.