Retrieve the friend list by page
Retrieve the current iOS user’s friend list with pagination.
Use the paginated selector to retrieve OIMFriendInfo objects instead of loading the entire friend list at once.
[[OIMManager manager] getFriendListPageWithOffset:0
count:50
filterBlack:YES
onSuccess:^(NSArray<OIMFriendInfo *> *friends) {
[friendStore replaceFirstPage:friends];
}
onFailure:nil];offset starts at 0, count is the page size, and filterBlack determines whether blocked users are excluded. The success callback returns the current page. When loading more, increment the offset by the number of requested items and deduplicate results by userID.
The query only establishes a snapshot and does not trigger a friendship delegate.
Synchronize friendship changes
This page is the sole owner of the complete handlers for onFriendAdded:, onFriendInfoChanged:, and onFriendDeleted:. Your application must retain a strong reference to one OIMFriendshipListener instance and use that same instance when adding and removing the listener.
@interface FriendshipStore () <OIMFriendshipListener>
@end
@implementation FriendshipStore
- (void)startListening {
[[OIMManager callbacker] addFriendListener:self];
}
- (void)stopListening {
[[OIMManager callbacker] removeFriendListener:self];
}
- (void)onFriendAdded:(OIMFriendInfo *)info {
[friendStore mergeFriend:info];
}
- (void)onFriendInfoChanged:(OIMFriendInfo *)info {
[friendStore mergeFriend:info];
}
- (void)onFriendDeleted:(OIMFriendInfo *)info {
[friendStore removeUserID:info.userID];
}
@endHandle the query snapshot and delegate updates separately, always merging them by userID. Call stopListening when signing out, switching accounts, or destroying the contacts state layer.
Was this page helpful?