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

Create a conversation group

Create a new conversation group and optionally assign an initial conversation to it.

Copy

Creating conversation groups is a Commercial Edition capability. When creating a custom group, supply the group name, order index, and group type. To associate an initial conversation with the new group immediately upon creation, supply conversationID.

Parameters

ParameterTypeRequiredDescription
namestringYesName of the conversation group.
ordernumberYesSequence order index used for tab or list sorting.
conversationGroupTypeOpenIMConversationGroupTypeYesUse OpenIMConversationGroupTypeNormal for custom user groups, or OpenIMConversationGroupTypeFilter for rule-filtered groups.
conversationIDstring | nullNoIdentifier of a conversation to add to the group immediately upon creation.
exstring | nullNoCustom application-defined extension string.

Code example

import {
  OpenIMConversationGroupTypeNormal,
  createConversationGroup,
} from '@/uni_modules/unix-openim-sdk'

const result = await createConversationGroup({
  name: 'Work',
  order: 100,
  conversationGroupType: OpenIMConversationGroupTypeNormal,
  conversationID,
})
const group = result?.conversationGroup

Return value

The Promise resolves with an OpenIMCreateConversationGroupResult | null object. The newly created group item is located in conversationGroup (OpenIMConversationGroupItem).

State changes after the call

Upon Promise resolution, insert or update the conversation group in your local view models using conversationGroupID as the merge key. When group events arrive or upon reconnecting, re-query the full group list to calibrate state as shown in Conversation group overview.