Browse SDKs · Android
Platform
SDKsAndroidEnterprise

Set friend request permissions

Configure verification rules for incoming friend requests targeting the authenticated account.

Copy

Configure how the server handles incoming friend applications sent by other users (such as requiring manual approval, auto-accepting, or rejecting all incoming requests). This capability belongs to the Commercial Edition.

Set the permission enum code in the user configuration request, then submit it via Update the current user profile:

Code example

UserInfoReq request = new UserInfoReq();
request.setAddFriendPermission(AddFriendPermission.Allow.getValue());

OpenIMClient.getInstance().userInfoManager.setSelfInfo(
    new OnBase<String>() {
        @Override
        public void onSuccess(String data) {
            // Friend request permissions updated successfully
        }

        @Override
        public void onError(int code, String error) {
            // Handle error
        }
    },
    request
);

Parameters

ParameterTypeRequiredDescription
baseOnBase<String>YesCallback delivering the asynchronous operation result.
requestUserInfoReqYesUser profile request payload containing the friend permission enum value.

Permission modes

Enum constantValueDescription
AddFriendPermission.Allow0Allows users to send friend requests, requiring manual review and approval by the recipient.
AddFriendPermission.AllowNoReview1Automatically accepts incoming friend requests without manual approval.
AddFriendPermission.Deny2Disallows any incoming friend requests to the account.

Return value

Upon success, data in onSuccess returns a confirmation message.

State changes after the call

  1. Callback confirmation: The onSuccess callback indicates that the server recorded the updated friend request permission.
  2. Scope of effect: This setting applies strictly to incoming friend requests initiated after the update. It does not alter existing friendships or auto-resolve pending friend applications.
  3. Asynchronous event delivery: The current account receives OnUserListener.onSelfInfoUpdated reflecting the updated user profile configuration.
  4. Re-query calibration: To review pending friend applications, see Get received friend applications.