SDKsHarmonyOSEnterprise
Check friend relationship
Batch verify whether specific users are mutual friends with the current account.
Batch check friendship status for an array of candidate user IDs:
Code example
import sdk, { CheckFriendReq, CheckFriendResp } from '@openimsdk/imsdk';
const request: CheckFriendReq = {
friendUserIDs: ['user_a', 'user_b'],
};
const response: CheckFriendResp = await sdk.checkFriend(request);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
friendUserIDs | string[] | Yes | List of user IDs to check. |
Return value
Returns a Promise that resolves to a CheckFriendResp object containing check results:
| Property | Type | Description |
|---|---|---|
userID | string | Evaluated user ID. |
result | CheckFriendResult | Friendship status: CheckFriendResult.IsFriend (1) or CheckFriendResult.NotFriend (0). |
State changes after the call
This method only inspects friendship status; it does not evaluate blocklist records (see Retrieve blocklist) or emit real-time events. For contact directory maintenance, see Paginate friend list.
Was this page helpful?