Browse SDKs · iOS
Platform
SDKsiOS

Create a group

Create a group and configure its initial members with the Objective-C API.

Copy

Invoke createGroup:onSuccess:onFailure: to create a new group and configure its base information, initial members, administrators, and group owner:

Parameters

ParameterTypeRequiredDescription
groupCreateInfoOIMGroupCreateInfo *YesCreation request model specifying group profile metadata, member lists, and ownership.

OIMGroupCreateInfo properties

ParameterTypeRequiredDescription
groupInfoOIMGroupBaseInfo *YesBase group metadata, including groupName and groupType (such as OIMGroupTypeWorking).
memberUserIDsNSArray<NSString *> *NoInitial list of regular member user IDs.
adminUserIDsNSArray<NSString *> *NoInitial list of administrator user IDs.
ownerUserIDNSString *NoGroup 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

  1. Local state update: The client inserts the new group into local storage using groupID as the primary key.
  2. Event notification: Active client sessions receive notifications through the onJoinedGroupAdded: listener callback.
  3. Re-query calibration: For comprehensive group event listener configuration, refer to Groups overview.