Browse SDKs · Android
SDKsAndroidEnterprise

Set friend request permissions

Choose how friend requests sent to the current account are handled.

Copy

Use addFriendPermission to choose whether requests from other users to add the current account require approval. This capability is available in the Enterprise edition.

Set the value with UserInfoReq.setAddFriendPermission(), then call setSelfInfo():

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

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

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

Permission values

Enum valueNumeric valueMeaning
AddFriendPermission.Allow0Allow requests, but require the current user to approve them.
AddFriendPermission.AllowNoReview1Allow requests and create the friendship without approval.
AddFriendPermission.Deny2Do not allow other users to add the current account.

A successful callback means that the update request completed. This setting affects subsequent attempts to add the account; it does not remove existing friendships or process friend requests that already exist.