Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Group overview

Understand group profiles, member relationships, applications, roles, and group events in the OpenIM HarmonyOS SDK.

Copy

OpenIMSDK organizes multi-user chats, shared profiles, memberships, and permissions through groups. Use groupID when sending group messages, updating group profiles, managing members, and processing group applications. The conversation record representing a group chat in the conversation list uses conversationID; do not confuse the two identifiers.

Core data models

ModelPurpose
IMGroupGroup name, avatar, announcement, owner, verification options, member count, and custom metadata.
IMGroupMemberA user’s group-specific nickname, role level, mute status, and join details.
IMGroupApplicationMembership application records and their review outcomes.

Member roles are represented by GroupMemberRoleLevel: ordinary members are GroupOrdinaryUsers, administrators are GroupAdmin, and the group owner is GroupOwner. Use role levels to control client UI actions; the server strictly validates all permissions.

Group profile fields

FieldTypeDescription
groupIDstringStable group identifier and event merge key.
groupNamestringGroup display title.
faceURLstringGroup avatar image URL.
notificationstringGroup announcement text.
introductionstringBrief group description.
ownerUserIDstringUser ID of the current group owner.
creatorUserIDstringUser ID of the group creator.
memberCountnumberTotal member count at query time.
needVerificationGroupNeedVerificationVerification policy for new applicants joining the group.
lookMemberInfoGroupLookMemberInfoPermission controlling member profile visibility.
applyMemberFriendGroupApplyMemberFriendPermission controlling whether members can add each other as friends from within the group.
statusGroupStatusGroup operational status (e.g., active, dismissed, muted).
createTimenumberGroup creation timestamp in Unix milliseconds.
exstringApplication-defined custom group metadata string.
attachedInfostringAdditional engine metadata.
isShowGroupReadbooleanServer configuration indicating whether message read receipts are displayed in this group.

Listen for group changes

Listen for group property changes, joins, departures, and group dissolutions to keep UI views synchronized in real time:

Code example

import sdk, {
  EventOnGroupDismissedData,
  EventOnGroupInfoChangedData,
  EventOnJoinedGroupAddedData,
  EventOnJoinedGroupDeletedData,
  OpenIMSDKEvent,
} from '@openimsdk/imsdk';

const handleJoinedGroupAdded = (data: EventOnJoinedGroupAddedData): void => {
  mergeGroup(data.group);
};
const handleJoinedGroupDeleted = (data: EventOnJoinedGroupDeletedData): void => {
  removeJoinedGroup(data.group.groupID);
};
const handleGroupInfoChanged = (data: EventOnGroupInfoChangedData): void => {
  mergeGroup(data.group);
};
const handleGroupDismissed = (data: EventOnGroupDismissedData): void => {
  markGroupDismissed(data.group.groupID);
};

const unsubscribeJoinedGroupAdded = sdk.on(
  OpenIMSDKEvent.EventOnJoinedGroupAdded,
  handleJoinedGroupAdded,
);
const unsubscribeJoinedGroupDeleted = sdk.on(
  OpenIMSDKEvent.EventOnJoinedGroupDeleted,
  handleJoinedGroupDeleted,
);
const unsubscribeGroupInfoChanged = sdk.on(
  OpenIMSDKEvent.EventOnGroupInfoChanged,
  handleGroupInfoChanged,
);
const unsubscribeGroupDismissed = sdk.on(
  OpenIMSDKEvent.EventOnGroupDismissed,
  handleGroupDismissed,
);

export function removeGroupListeners(): void {
  unsubscribeJoinedGroupAdded();
  unsubscribeJoinedGroupDeleted();
  unsubscribeGroupInfoChanged();
  unsubscribeGroupDismissed();
}

State changes after the call

Detach listeners using removeGroupListeners() upon account sign-out or when terminating the group manager. API Promise resolution, event notifications, and re-querying snapshots represent three separate lifecycle phases. If membership changes occur during active pagination, reset the pagination offset and re-query from page 1.