Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook SDK: openActiveSessionWithPermissions completionHandler not called

Using the code from Facebook I have implemented

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
    NSArray *permissions = [[NSArray alloc] initWithObjects:
    @"publish_actions", 
    nil];

    return [FBSession openActiveSessionWithPermissions:permissions
                                      allowLoginUI:allowLoginUI
                                 completionHandler:^(FBSession *session,
                                                     FBSessionState state,
                                                     NSError *error) {
   NSLog(@"error %@", error);                                     
    [self sessionStateChanged:session
                        state:state
                        error:error];
                                 }];
}

It returns NO which I understand because it's a first time login, and the loginUI works (it sends the user to FB and asks them to give permissions) and then returns but completionHandler block is never ever run. It just returns to the app and nada.

like image 302
Will Larche Avatar asked Feb 19 '23 02:02

Will Larche


1 Answers

I assume you following Implement the Login Flow of Facebook SDK but worth reading that section again as it explains everything. Make sure that you handled openURL and handleOpenURL methods in delegate. Also check openSessionWithAllowLoginUI almost always returns NO

like image 75
AlienMonkeyCoder Avatar answered Apr 08 '23 20:04

AlienMonkeyCoder