iphone - Facebook SDK : openActiveSessionWithPermissions completionHandler not called

标签 iphone ios facebook facebook-ios-sdk

使用我已经实现的来自 Facebook 的代码

- (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];
                                 }];
}

它返回 NO,我理解这是因为这是第一次登录,并且 loginUI 工作(它将用户发送到 FB 并要求他们授予权限)然后返回,但 completionHandler block 永远不会运行。它只是返回到应用程序和 nada。

最佳答案

我假设您关注 Implement the Login Flow Facebook SDK 但值得再次阅读该部分,因为它解释了一切。确保您在委托(delegate)中处理了 openURL 和 handleOpenURL 方法。还要检查 openSessionWithAllowLoginUI almost always returns NO

关于iphone - Facebook SDK : openActiveSessionWithPermissions completionHandler not called,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12514740/

相关文章:

iphone - 是否可以在 Cocoa Touch 中观察对象的只读属性?

ios - FireBase 查询不适用于 Swift 3.0

ios - 使用NSLayoutConstraint时引起的编译错误

javascript - FB.getAuthResponse().expiresIn 的单位是什么?

javascript - Facebook 身份验证对话框 : Developer warning concerning the use of "display" type "popup"

python - django-social-auth 中的 Django 错误

iphone - 在cocos2d中检测触摸*屏幕上的任何地方*?

iphone - 钛金 iOS 模块

iphone - 编译时Xcode总线错误

ios - 从应用程序中的所有图像创建数组?