Browse SDKs · React Native
Platform
SDKsReact Native

Create a group

OpenIM React Native SDK guide for create a group.

Copy

Call createGroup() to create a group and set its initial members, administrators, and owner.

const group = await OpenIMSDK.createGroup({
  memberUserIDs: ['user-003', 'user-004'],
  adminUserIDs: ['user-002'],
  ownerUserID: currentUserID,
  groupInfo: {
    groupName: 'Project discussion group',
    groupType: GroupType.WorkingGroup,
    faceURL: 'https://example.com/group.png',
  },
});

Parameters

ParameterTypeRequiredDescription
memberUserIDsstring[]YesUser IDs of the initial regular members.
adminUserIDsstring[]NoUser IDs of the initial administrators.
ownerUserIDstringNoUser ID of the group owner. The current user is used when omitted.
groupInfoPartial<GroupItem>YesInitial group profile. Common fields include groupName, groupType, and faceURL.

A regular member, administrator, and owner cannot be the same user. Use GroupType.WorkingGroup for groupInfo.groupType to create a regular group.

Return value

When the call completes, it returns the newly created GroupItem. Use the returned groupID to open the group profile or group chat. When the current account joins the group, OnJoinedGroupAdded returns the group information; see Group overview for event handling.