0

I'm trying to get all Facebook friends that uses my App. This is my code:

FBRequest* friendsRequest = [FBRequest requestForMyFriends];
          [friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
                                                   NSDictionary* result,
                                                   NSError *error) {
          NSArray* friends = [result objectForKey:@"data"];
          NSLog(@"Found: %i friends", friends.count);
          _fbIDsArray = NSMutableArray.array;

          for (NSDictionary<FBGraphUser>* friend in friends) {
               NSLog(@"I have a friend named %@ with id %@", friend.name, friend.objectID);
               [_fbIDsArray addObject:friend.objectID];
          }

When I'm working with the Facebook test user it returns friends, but when I try to find friends with a real account it returns nil. The App Status on Facebook is public. I'm using Facebook SDK 3.20

UPDATE

This worked for me

FBLoginView * loginView = [[FBLoginView alloc] initWithReadPermissions:@[@"public_profile", @"email", @"user_friends"]];
        loginView.delegate = self;
        NSArray *permissions = @[@"public_profile", @"email", @"user_friends"];
    
        [FBSession openActiveSessionWithReadPermissions:permissions
                                           allowLoginUI:YES
                                      completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
                                          [[FBRequest requestForMe] startWithCompletionHandler:
                                           ^(FBRequestConnection *connection,
                                             NSDictionary<FBGraphUser> *user,
                                             NSError *error)
                                           }];
                                      }]; 

     
Community
  • 1
  • 1
Lukas
  • 21
  • 1
  • 5

1 Answers1

0

In the latest Facebook SDK, you can get the list of such friends who is using the app. For more info please refer the following link - https://developers.facebook.com/docs/facebook-login/permissions/v2.2#reference-friends