Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Check friend relationship

Batch verify whether specific users are mutual friends with the current account.

Copy

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

ParameterTypeRequiredDescription
friendUserIDsstring[]YesList of user IDs to check.

Return value

Returns a Promise that resolves to a CheckFriendResp object containing check results:

PropertyTypeDescription
userIDstringEvaluated user ID.
resultCheckFriendResultFriendship 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.