SDKsHarmonyOSEnterprise
Check group membership
Check whether a specified user is a member of the target group.
The HarmonyOS API accepts both group ID and user ID, allowing you to check either the current account or other users where permitted.
Code example
import sdk, { IsJoinGroupReq, IsJoinGroupResp } from '@openimsdk/imsdk';
const request: IsJoinGroupReq = {
groupID: groupID,
userID: currentUserID,
};
const response: IsJoinGroupResp = await sdk.isJoinGroup(request);
if (response.joined) {
showGroupMemberActions();
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
groupID | string | Yes | Target group identifier. |
userID | string | Yes | User ID to check for membership. |
Return value
Returns a Promise resolving to IsJoinGroupResp:
| Property | Type | Description |
|---|---|---|
joined | boolean | true if the user is currently in the group; otherwise false. |
State changes after the call
This method checks membership snapshot status at the time of invocation and does not fire events. To continuously maintain membership state for the current account, listen to group joined, left, and dismissed events as described in Group overview, and recalibrate after reconnects or key lifecycle operations.
Was this page helpful?