SDKsiOS
Create a group
Create a group and configure its initial members with the Objective-C API.
Invoke createGroup:onSuccess:onFailure: to create a new group and configure its base information, initial members, administrators, and group owner:
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
groupCreateInfo | OIMGroupCreateInfo * | Yes | Creation request model specifying group profile metadata, member lists, and ownership. |
OIMGroupCreateInfo properties
| Parameter | Type | Required | Description |
|---|---|---|---|
groupInfo | OIMGroupBaseInfo * | Yes | Base group metadata, including groupName and groupType (such as OIMGroupTypeWorking). |
memberUserIDs | NSArray<NSString *> * | No | Initial list of regular member user IDs. |
adminUserIDs | NSArray<NSString *> * | No | Initial list of administrator user IDs. |
ownerUserID | NSString * | No | Group owner user ID, typically the currently signed-in user. User IDs must not duplicate across member, admin, and owner assignments. |
Code example
OIMGroupBaseInfo *base = [OIMGroupBaseInfo new];
base.groupName = @"Project Discussion";
base.groupType = OIMGroupTypeWorking;
OIMGroupCreateInfo *request = [OIMGroupCreateInfo new];
request.groupInfo = base;
request.memberUserIDs = @[@"user-003"];
request.adminUserIDs = @[@"user-002"];
request.ownerUserID = currentUserID;
[[OIMManager manager] createGroup:request
onSuccess:^(OIMGroupInfo *group) {
[self openGroupWithID:group.groupID];
}
onFailure:^(NSInteger code, NSString *message) {
NSLog(@"createGroup failed: %ld %@", (long)code, message);
}];Return value
The onSuccess callback delivers the fully initialized OIMGroupInfo object, including the newly assigned groupID.
State changes after the call
- Local state update: The client inserts the new group into local storage using
groupIDas the primary key. - Event notification: Active client sessions receive notifications through the
onJoinedGroupAdded:listener callback. - Re-query calibration: For comprehensive group event listener configuration, refer to Groups overview.
Was this page helpful?