I found numerous solutions here for getting my friends on Facebook in an iOS app. I wrote something similar that worked for a while, shown below. But as of yesterday, it's only getting one friend instead of all 100 of my friends. Yes, I checked just now to make sure 99 of them didn't unfriend me. That one friend is my second account, which is also signed up as a tester for my app.
Here's what I've been using after the user has logged into Facebook on the app:
FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error) {
NSArray* tempFriends = [result objectForKey:@"data"];
NSLog(@"NetworkHandler retrieved friend list (%lu friends).", (unsigned long)tempFriends.count);
for (NSDictionary<FBGraphUser>* user in tempFriends){
// Handle retrieved friends...
}
}];
Output: "NetworkHandler retrieved friend list (1 friends)."
I've tried setting a breakpoint in the completion block to be sure. The array has one item, an id<FBGraphUser>
representing my second account.