Browse SDKs · Android
Platform
SDKsAndroid

Accept a friend application

Approve a friend request from a specified user and establish a bilateral friendship using acceptFriendApplication().

Copy

Accept an incoming friend request from a specified user to establish a bilateral friendship.

Code example

OpenIMClient.getInstance().friendshipManager.acceptFriendApplication(
    new OnBase<String>() {
        @Override
        public void onSuccess(String data) {
            // Friend application accepted successfully
        }

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

Parameters

ParameterTypeRequiredDescription
baseOnBase<String>YesCallback delivering the asynchronous operation result.
applicantUserIDStringYesUser ID of the applicant who submitted the request.
handleMsgStringNoOptional approval note attached to the resolution.

Return value

The successful callback indicates that the server recorded the acceptance and established a bilateral friendship between the accounts.

State changes after the call

Upon acceptance, the SDK delivers events through OnFriendshipListener:

  • onFriendApplicationAccepted(FriendApplicationInfo application): Reports that the request status transitioned to approved. Update the matching application item using application.getFromUserID().
  • onFriendAdded(FriendInfo friend): Reports that the new friend was added to the contacts roster. Insert the friend into your local cache using friend.getUserID().

For complete listener registration details, see Get the friend list.