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

Conversation group overview

OpenIM uni-app / uni-app x SDK guide for Conversation group overview.

Copy

Conversation groups are Commercial. They organize conversations into custom groups with a name, order, hidden state, unread snapshot, and member conversation IDs.

Group types

Creation uses OpenIMConversationGroupType; queries use OpenIMConversationGroupQueryType. They belong to different operation contracts. Do not pass a UI tab index directly as either SDK type.

One conversation can belong to several groups. Groups organize conversation entry points; they do not copy or move message data. Deleting a group or removing membership does not delete the underlying conversation.

Group data

Every OpenIMConversationGroupItem field is optional:

FieldTypeDescription
conversationGroupIDstring or nullStable group identifier. Cache only after validating it.
namestring or nullGroup name.
ordernumber or nullSort value.
exstring or nullApplication extension; parse only a confirmed format.
conversationGroupTypenumber or nullGroup type.
hiddenboolean or nullWhether the group is hidden.
unreadCountnumber or nullGroup-level unread snapshot.
conversationIDsstring[] or nullMember IDs included in this response; it might not be a complete paginated set.

Use a non-empty conversationGroupID as the index key. Names, order, and hidden state can change. Query group information with conversations when complete membership, conversation objects, and total count are needed.

Available operations

TaskPage
Create a group and optionally add one initial conversationCreate a conversation group
Query groupsGet conversation groups
Query group metadata, members, and total countGet a group with its conversations
Query all groups containing one conversationGet groups for a conversation
Add or remove membershipAdd conversations to groups, Remove conversations from groups
Update name, extension, or hidden stateUpdate a conversation group
Change group orderingSet conversation-group order
Delete a groupDelete a conversation group

Query a snapshot when the page opens. After a mutation Promise succeeds, continue to wait for an event or requery. When raw event fields are not frozen, never replace a query result with guessed local state.

Listen for group changes

The five group events return opaque JSON strings rather than typed objects:

import {
  off,
  onConversationGroupAdded,
  onConversationGroupChanged,
  onConversationGroupDeleted,
  onConversationGroupMemberAdded,
  onConversationGroupMemberDeleted,
} from '@/uni_modules/unix-openim-sdk'

function refreshFromRawGroupEvent(payload : string) {
  try {
    const value = JSON.parseObject<UTSJSONObject>(payload)
    if (value != null) refreshConversationGroups()
  } catch (_) {
    console.error('Invalid conversation group event payload')
  }
}

const addedSubscription = onConversationGroupAdded(refreshFromRawGroupEvent)
const subscriptions : Array<OpenIMSDKEventSubscription> = [
  addedSubscription,
  onConversationGroupChanged(refreshFromRawGroupEvent),
  onConversationGroupDeleted(refreshFromRawGroupEvent),
  onConversationGroupMemberAdded(refreshFromRawGroupEvent),
  onConversationGroupMemberDeleted(refreshFromRawGroupEvent),
]
subscriptions.forEach((subscription) => off(subscription))

The added, changed, and deleted events describe group objects; the member-added and member-deleted events describe membership. Because the raw payload has no frozen DTO, validate only that it is valid JSON and then requery the related snapshot.

Do not depend on unfrozen fields after JSON validation. Handlers should return quickly and isolate refresh tasks by the current logged-in user. Stop old-account writes before releasing each handle on account switch or dispose. Never log a complete payload because ex and other fields can contain application data.