SDKsiOSIncludes Enterprise features
Retrieve received friend requests
Retrieve friend requests received by the current iOS user with pagination.
Retrieve friend requests received by the current user with pagination using getFriendApplicationListAsRecipientWithReq:onSuccess:onFailure:.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
req | GetFriendApplicationListAsRecipientReq * | Yes | Request object configuring status filters and pagination limits. |
Request attributes (GetFriendApplicationListAsRecipientReq)
| Parameter | Type | Required | Description |
|---|---|---|---|
handleResults | NSArray<NSNumber *> * | No | Status filter list. Pass @[@(OIMApplicationStatusNormal)] to query pending, unhandled applications. |
offset | NSInteger | Yes | Pagination starting offset. Pass 0 for the first page. |
count | NSInteger | Yes | Number of request items to fetch per page. |
Code example
GetFriendApplicationListAsRecipientReq *req = [GetFriendApplicationListAsRecipientReq new];
req.handleResults = @[@(OIMApplicationStatusNormal)];
req.offset = 0;
req.count = 20;
[[OIMManager manager] getFriendApplicationListAsRecipientWithReq:req
onSuccess:^(NSArray<OIMFriendApplication *> *items) {
[requestStore replaceReceived:items];
}
onFailure:^(NSInteger code, NSString *message) {
NSLog(@"getFriendApplicationListAsRecipient failed: %ld %@", (long)code, message);
}];Return value
The onSuccess callback returns an NSArray<OIMFriendApplication *> * containing received application records for the requested page.
State changes after the call
- Local state merge: Merge friend application records using
fromUserID:toUserIDorfromUserIDas the unique entity key. - Asynchronous event listening: Observe incoming, accepted, rejected, or deleted friend applications via the
OIMFriendshipListenerprotocol.
- (void)onFriendApplicationAdded:(OIMFriendApplication *)item {
[requestStore upsertApplication:item];
}
- (void)onFriendApplicationAccepted:(OIMFriendApplication *)item {
[requestStore upsertApplication:item];
}
- (void)onFriendApplicationRejected:(OIMFriendApplication *)item {
[requestStore upsertApplication:item];
}
- (void)onFriendApplicationDeleted:(OIMFriendApplication *)item {
[requestStore removeFromUserID:item.fromUserID toUserID:item.toUserID];
}Implement these callbacks in your primary OIMFriendshipListener instance (see Retrieve the friend list by page). Filter records into the incoming or outgoing application list based on whether toUserID matches the current logged-in user.
Was this page helpful?