Browse SDKs · Android
Platform
SDKsAndroidIncludes Enterprise features

Get received friend applications

Paginate friend requests received by the authenticated account using getRecvFriendApplicationList().

Copy

Paginate friend requests received by the authenticated account along with their approval states. This is typically used to render the "New Friends" view in a contacts screen.

Code example

GetFriendApplicationListAsRecipientReq request =
    new GetFriendApplicationListAsRecipientReq(0, 20);

OpenIMClient.getInstance().friendshipManager.getRecvFriendApplicationList(
    new OnBase<List<FriendApplicationInfo>>() {
        @Override
        public void onSuccess(List<FriendApplicationInfo> applications) {
            // Update received friend requests UI using applications
        }

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

Parameters

ParameterTypeRequiredDescription
baseOnBase<List<FriendApplicationInfo>>YesCallback delivering the asynchronous operation result.
requestGetFriendApplicationListAsRecipientReqYesRequest payload holding paging parameters offset and count.

Paging request attributes

FieldTypeDescription
offsetintZero-based paging offset; pass 0 for the first page.
countintNumber of application items requested for this page.

Return value

The successful callback returns the current page as List<FriendApplicationInfo>. Deduplicate and merge entries into your local list using the applicant's user ID (fromUserID) as the primary key. Each record exposes:

FieldDescription
fromUserID / fromNickname / fromFaceURLUser ID, display nickname, and avatar URL of the applicant.
toUserID / toNickname / toFaceURLUser ID, nickname, and avatar of the recipient (the authenticated user).
reqMsgGreeting or verification message provided by the applicant.
handleResultApproval result: 0 for pending, 1 for approved, -1 or 2 for rejected.
handlerUserIDUser ID of the user who evaluated the application.
handleMsgNote or explanation attached by the reviewer.
handleTimeUnix timestamp when the request was reviewed.
createTimeUnix timestamp when the application was submitted.
exCustom extension string attached to the application.

State changes after the call

Friend application events arrive in real time through OnFriendshipListener:

@Override
public void onFriendApplicationAdded(FriendApplicationInfo application) {
    // Process new or updated friend applications
}

@Override
public void onFriendApplicationAccepted(FriendApplicationInfo application) {
    // Process accepted friend applications
}

@Override
public void onFriendApplicationRejected(FriendApplicationInfo application) {
    // Process rejected friend applications
}

@Override
public void onFriendApplicationDeleted(FriendApplicationInfo application) {
    // Process deleted friend applications
}

Route records into received or sent collections based on whether toUserID equals the current user's ID. When an application is accepted, the SDK dispatches onFriendAdded to notify the client of the newly established friendship; see Get the friend list.