Create a group
OpenIM React Native SDK guide for create a group.
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
| Parameter | Type | Required | Description |
| --- | --- | --- |
| memberUserIDs | string[] | Yes | User IDs of the initial regular members. |
| adminUserIDs | string[] | No | User IDs of the initial administrators. |
| ownerUserID | string | No | User ID of the group owner. The current user is used when omitted. |
| groupInfo | Partial<GroupItem> | Yes | Initial 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.
Was this page helpful?