Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Set friend request permission

Configure the verification policy applied when other users send friend requests to the current account.

Copy

This account-level policy governs incoming friend requests. It only affects subsequent friend applications and does not alter existing friendships or pending requests:

Code example

import sdk, { AddFriendPermission, SetSelfInfoReq } from '@openimsdk/imsdk';

const request: SetSelfInfoReq = {
  userID: currentUserID,
  addFriendPermission: AddFriendPermission.AddFriendAllowed,
};
await sdk.setSelfInfo(request);

Parameters

ParameterTypeRequiredDescription
userIDstringYesSigned-in user identifier.
addFriendPermissionAddFriendPermissionYesFriend request verification policy.
OptionValueDescription
AddFriendPermission.AddFriendAllowed0Allow applications; requires manual approval by the current user.
AddFriendPermission.AddFriendAllowedNoReview1Automatically accept friend requests without manual review.
AddFriendPermission.AddFriendDenied2Reject all incoming friend requests.

Return value

Returns a Promise that resolves to void when the setting is saved on the server.

State changes after the call

Resolving the Promise confirms that the permission policy has been updated. To verify the active policy, call Retrieve current user profile and inspect addFriendPermission on the returned IMUser record.