Browse SDKs · uni-app / uni-app x
SDKsuni-app

Create a group

OpenIM uni-app / uni-app x SDK guide for Create a group.

Copy

createGroup() creates a group with initial profile data and member lists.

Parameters

ParameterTypeRequiredDescription
groupInfo.groupNamestringYesGroup name.
groupInfo.groupType2YesGroup type supported by the current contract.
groupInfo.notificationstring or nullNoInitial announcement.
groupInfo.introductionstring or nullNoInitial introduction.
groupInfo.faceURLstring or nullNoAvatar URL.
groupInfo.exstring or nullNoComplete extension string.
memberUserIDsstring[]YesInitial regular members.
adminUserIDsstring[] or nullNoInitial administrators.
import { createGroup } from '@/uni_modules/unix-openim-sdk'

const group = await createGroup({
  groupInfo: { groupName: 'Project group', groupType: 2 },
  memberUserIDs: ['user_b', 'user_c'],
  adminUserIDs: ['user_b'],
})

Remove blank and duplicate member IDs first. Administrators must also satisfy the server's membership and role rules; do not put the same user into conflicting role lists. ex is not merged as JSON by the SDK.

Return result

The Promise resolves directly to OpenIMGroupItem or null. Merge a non-null result into the group store by groupID; do not create a local-only group for null.

Promise success means that the creation request completed, not that every optional membership change has been observed. Reconcile the group list through onJoinedGroupAdded or a group query, and verify initial members and administrators through the member list.