Facebook SDK: openActiveSessionWithPermissions completionHandler not called

冷暖自知 提交于 2019-12-12 12:24:30

问题


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.


回答1:


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




回答2:


Little late, but just in case someone comes checking...

Switching from openActiveSession to the instance method openWithCompletionHandler did the trick for me.




回答3:


from the official doc

handler

... If a block is provided, the FBSession object will call the block each time the session changes state.

I fixed this problem my solving Open Graph setups and by studying Scrumptious example code from FB such as these functions [FBSession.activeSession handleOpenURL:url] and [FBSession.activeSession handleDidBecomeActive];



来源:https://stackoverflow.com/questions/12514740/facebook-sdk-openactivesessionwithpermissions-completionhandler-not-called

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!