SDKsiOSEnterprise
Create a conversation group
Create a conversation group with OpenIM iOS SDK.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
name | NSString * | Yes | Name of the conversation group. |
order | NSNumber * | No | Sorting order index for group display. |
ex | NSString * | No | Custom extension string. |
conversationID | NSString * | No | ID of a conversation to include immediately upon creation. |
conversationGroupType | NSNumber * | No | Group 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
- Local state update: The client parses the JSON response and inserts or updates the group record using
conversationGroupIDas the unique key. - Event notification: Multi-device synchronization or subsequent changes broadcast via the
onConversationGroupAdded:listener callback. - Re-query calibration: For comprehensive listener configuration and data structures, refer to Conversation groups overview.
Was this page helpful?