SDKsHarmonyOSEnterprise
Set friend request permission
Configure the verification policy applied when other users send friend requests to the current account.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
userID | string | Yes | Signed-in user identifier. |
addFriendPermission | AddFriendPermission | Yes | Friend request verification policy. |
| Option | Value | Description |
|---|---|---|
AddFriendPermission.AddFriendAllowed | 0 | Allow applications; requires manual approval by the current user. |
AddFriendPermission.AddFriendAllowedNoReview | 1 | Automatically accept friend requests without manual review. |
AddFriendPermission.AddFriendDenied | 2 | Reject 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.
Was this page helpful?