SDKsAndroid
Get received friend requests
Use getRecvFriendApplicationList() to query received friend requests by page.
GetFriendApplicationListAsRecipientReq request =
new GetFriendApplicationListAsRecipientReq(0, 20);
OpenIMClient.getInstance().friendshipManager.getRecvFriendApplicationList(
new OnBase<List<FriendApplicationInfo>>() {
@Override
public void onSuccess(List<FriendApplicationInfo> applications) {
replaceReceivedApplications(applications);
}
@Override
public void onError(int code, String error) {
recordReceivedApplicationFailure(code, error);
}
},
request
);offset starts at 0, and count is the page size. To filter by handling state, use setHandleResults(int[]) with values defined by the server contract. The callback returns the current page as List<FriendApplicationInfo>.
| Field | Description |
|---|---|
fromUserID / fromNickname / fromFaceURL | Applicant ID, nickname, and avatar snapshot. |
toUserID / toNickname / toFaceURL | Recipient ID, nickname, and avatar snapshot. |
reqMsg | Friend request message. |
handleResult | Handling result: 0 pending, 1 accepted, 2 rejected. |
handlerUserID | User ID that handled the request; it can be empty while pending. |
handleMsg | Handling message. |
handleTime | Handling time; do not treat it as valid while pending. |
createTime | Request creation time. |
ex | Friend request extension string. |
Use fromUserID:toUserID as the stable request key. This page owns the friend request added, accepted, rejected, and deleted callbacks. Combine them into the application's single OnFriendshipListener:
@Override
public void onFriendApplicationAdded(FriendApplicationInfo application) {
friendApplicationStore.merge(application);
}
@Override
public void onFriendApplicationAccepted(FriendApplicationInfo application) {
friendApplicationStore.merge(application);
}
@Override
public void onFriendApplicationRejected(FriendApplicationInfo application) {
friendApplicationStore.merge(application);
}
@Override
public void onFriendApplicationDeleted(FriendApplicationInfo application) {
friendApplicationStore.remove(
application.getFromUserID(),
application.getToUserID()
);
}Use whether toUserID equals the signed-in user ID to route a record to the received or sent list. After an application is accepted, onFriendAdded, owned by Get the friend list by page, merges the new friendship.
Was this page helpful?