Browse SDKs · iOS
Platform
SDKsiOSIncludes Enterprise features

Retrieve received friend requests

Retrieve friend requests received by the current iOS user with pagination.

Copy

Retrieve friend requests received by the current user with pagination using getFriendApplicationListAsRecipientWithReq:onSuccess:onFailure:.

Parameters

ParameterTypeRequiredDescription
reqGetFriendApplicationListAsRecipientReq *YesRequest object configuring status filters and pagination limits.

Request attributes (GetFriendApplicationListAsRecipientReq)

ParameterTypeRequiredDescription
handleResultsNSArray<NSNumber *> *NoStatus filter list. Pass @[@(OIMApplicationStatusNormal)] to query pending, unhandled applications.
offsetNSIntegerYesPagination starting offset. Pass 0 for the first page.
countNSIntegerYesNumber 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:toUserID or fromUserID as the unique entity key.
  • Asynchronous event listening: Observe incoming, accepted, rejected, or deleted friend applications via the OIMFriendshipListener protocol.
- (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.