Browse SDKs · Android
Platform
SDKsAndroid

Refuse a friend application

Decline a friend request from a specified user with an optional rejection reason using refuseFriendApplication().

Copy

Decline an incoming friend request from a specified user with an optional reason note.

Code example

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

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

Parameters

ParameterTypeRequiredDescription
baseOnBase<String>YesCallback delivering the asynchronous operation result.
applicantUserIDStringYesUser ID of the applicant who submitted the request.
handleMsgStringNoOptional rejection explanation note.

Return value

The successful callback indicates that the server recorded the rejection status.

State changes after the call

Upon rejection, the SDK dispatches the onFriendApplicationRejected(FriendApplicationInfo application) event via OnFriendshipListener. Locate the matching entry in your received requests list using application.getFromUserID() and update its status to rejected.

For complete listener registration details, see Get received friend applications.