Chase Roberts
Chase Roberts

Reputation: 9386

Facebook SDK 3.5 FBSession openWithCompletionHandler isn't calling the completion handler

I am trying to just get some basic info from facebook in my app. I run this code:

FBSession *session = [[FBSession alloc] initWithAppID:APP_ID permissions:nil defaultAudience:FBSessionDefaultAudienceEveryone urlSchemeSuffix:nil tokenCacheStrategy:nil];
NSLog(@"I get this message");

[session openWithCompletionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
    NSLog(@"It never calls this");
}];

It seems the handler is just never called. I am taken to facebook and brought back but nothing happens. Anyone have any ideas?

Upvotes: 2

Views: 2456

Answers (1)

Chase Roberts
Chase Roberts

Reputation: 9386

I still don't know why it didn't work, but this is what did.

FBSession *session = [[FBSession alloc] initWithAppID:APP_ID permissions:nil defaultAudience:FBSessionDefaultAudienceEveryone urlSchemeSuffix:nil tokenCacheStrategy:nil];
[FBSettings setDefaultAppID: APP_ID];
[FBSession setActiveSession:session];
[FBSession openActiveSessionWithReadPermissions:@[@"basic_info", @"email"] allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
    if ([session isOpen]) {
        [FBRequestConnection 
          startForMeWithCompletionHandler:^(FBRequestConnection *connection,
                                               id<FBGraphUser> FBUser,
                                               NSError *error) {
              if (!error){
                //do whatever you need to.
              }
         }];
     }
}];

Upvotes: 2

Related Questions