FBSDKLoginManagerLoginResult返回iOS 11

时间:2017-09-25 08:22:15

标签: objective-c facebook facebook-sdk-4.0 ios11 fbsdkloginkit

使用iOS 11 FBSDKLoginManager(v.4.25.0)使用SFAuthenticationSession而不是SFSafariViewController,如果用户取消登录,则FBSDKLoginManagerLoginResult始终返回nil并且result.isCancelled代码不起作用:

[[FBSDKLoginManager new] logInWithReadPermissions:@[PERMISSIONS]
                               fromViewController:self
                                          handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
                            if (error) {
                               //Error happen
                            }
                            else if (result.isCancelled) {
                               //User cancel
                            }
                            else {
                               //Login success
                            }
                        }];

在这种情况下,总是会发生错误,描述为'com.apple.SafariServices.Authentication Code = 1“(null)”'。因此,在这种情况下,我们无法从SFAuthenticationSession错误中识别出真正的错误。任何想法如何处理不同的错误?或者只需要等待FBSDK更新?

1 个答案:

答案 0 :(得分:0)

我正在使用带有 ios 11 的FBSDK版本[ 4.17.0 ]并且工作正常

  let facebookLogin = FBSDKLoginManager()

    facebookLogin.logOut()

    facebookLogin.logIn(withReadPermissions: ["public_profile","email", "user_friends"], from:self, handler:
        {


            (facebookResult, facebookError) -> Void in


            if facebookError != nil
            {
                print("Facebook login failed. Error \(String(describing: facebookError))")
            }
            else if (facebookResult?.isCancelled)!
            {


                print("Facebook login was cancelled.")

            }
            else
            {


            }
    })