iosobjective-cfacebook-requestsfacebook-sdk-3.0

FBRequest issue - get the friends' info


I'm trying to get the friends' birthday, location, and names by sending the FBRequest and show the results on a table in a different view. But I always receive nil response. I've set the permissions first, and then created a request with the required fields:

NSArray *permissions = [[NSArray alloc] initWithObjects:
                        @"user_birthday",@"friends_hometown",
                        @"friends_birthday",@"friends_location",
                        nil];

if (!FBSession.activeSession.isOpen) {
    [FBSession openActiveSessionWithReadPermissions:permissions
                                       allowLoginUI:YES
                                  completionHandler:^(FBSession *session,
                                                      FBSessionState state,
                                                      NSError *error) {
                                      if (error) {
                                          UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
                                                                                              message:error.localizedDescription
                                                                                             delegate:nil
                                                                                    cancelButtonTitle:@"OK"
                                                                                    otherButtonTitles:nil];
                                          [alertView show];
                                      } else if (session.isOpen) {
                                          NSLog(@"permissions::%@",session.permissions);

                                          NSLog(@"Open");
                                          FTBFriendTableViewController *ftbFriendTableViewController= [[FTBFriendTableViewController alloc] initWithNibName:@"FTBFriendTableViewController" bundle:nil];
                                          FTBAppDelegate *delegate=(FTBAppDelegate*)[[UIApplication sharedApplication] delegate];

                                          if (ftbFriendTableViewController.friendList == nil){
                                              ftbFriendTableViewController.friendList = [[NSMutableArray alloc] init];
                                          }
                                         FBRequest *friendRequest = [FBRequest requestForGraphPath:@"me/friends?fields=name,birthday,location"];

                                          [ friendRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                                              ftbFriendTableViewController.friendList = [result objectForKey:@"data"];
                                              for (FBGraphObject<FBGraphUser> *friend in test) {
                                                  NSLog(@"%@:%@", [friend name],[friend birthday]);
                                              }}];

                                          delegate.window.rootViewController = ftbFriendTableViewController;

                                      }
                                  }];
    return;
}

I've also set FacebookAppID, FacebookDisplayName, and URL identifier in the application plist. This is the actual request which is sent:

FBRequest: 0x94c1080, session: 0xa1c5600, graphPath: me/friends?fields=name,birthday,location, HTTPMethod: GET, parameters: { "migration_bundle" = "fbsdk:20130409"; }

Any idea what else can cause no response issue? Thanks!


Solution

  • I found the issue. When you add the "URL types" parameter in .plist, XCode adds "URL identifier" by default. For the Facebook app, we should add "URL Schemes" instead of "URL identifier" and assign fb[FacebookAppID] as the value.