Get received friend applications
Paginate friend requests received by the authenticated account using getRecvFriendApplicationList().
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
| Parameter | Type | Required | Description |
|---|---|---|---|
base | OnBase<List<FriendApplicationInfo>> | Yes | Callback delivering the asynchronous operation result. |
request | GetFriendApplicationListAsRecipientReq | Yes | Request payload holding paging parameters offset and count. |
Paging request attributes
| Field | Type | Description |
|---|---|---|
offset | int | Zero-based paging offset; pass 0 for the first page. |
count | int | Number 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:
| Field | Description |
|---|---|
fromUserID / fromNickname / fromFaceURL | User ID, display nickname, and avatar URL of the applicant. |
toUserID / toNickname / toFaceURL | User ID, nickname, and avatar of the recipient (the authenticated user). |
reqMsg | Greeting or verification message provided by the applicant. |
handleResult | Approval result: 0 for pending, 1 for approved, -1 or 2 for rejected. |
handlerUserID | User ID of the user who evaluated the application. |
handleMsg | Note or explanation attached by the reviewer. |
handleTime | Unix timestamp when the request was reviewed. |
createTime | Unix timestamp when the application was submitted. |
ex | Custom 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.
Was this page helpful?