FBSDKLoginManagerLoginResult return nil iOS 11

785 views Asked by At

With iOS 11 FBSDKLoginManager (v.4.25.0) use SFAuthenticationSession instead of SFSafariViewController, if user cancel Sign In, FBSDKLoginManagerLoginResult always return nil and result.isCancelled code not work:

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

In this case always happen error with description 'com.apple.SafariServices.Authentication Code=1 "(null)"'. So, in this case, we can't discern really error from SFAuthenticationSession error. Any ideas how to handle different errors? Or just need to wait FBSDK update?

1

There are 1 answers

0
sheko On

I'm using FBSDK version [ 4.17.0 ] with ios 11 and it works fine

  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
            {


            }
    })