简体   繁体   中英

Facebook is not returning data in didCompleteWithResult in iOS 9

I am trying to implement Facebook login, it's working good for iOS 8.4 and it was working good for iOS 9.1 as well however today morning I found it faulty.

It's returning nothing in below delegate function so app closes in testing device

func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!)
{
NSLog("Here")
if let b = result
    {
    if ((error) != nil)
    {
        FBSDKLoginManager().logOut()
        JLToast.makeText("Facebook login error").show()
    }
    else if result.isCancelled {

        self.fbloginButton.enabled = false
        FBSDKLoginManager().logOut()
        FBSDKAccessToken.setCurrentAccessToken(nil)
        JLToast.makeText("You have cancelled facebook login").show()
        self.dismissViewControllerAnimated(true, completion: nil)
    }
    else {
        // If you ask for multiple permissions at once, you
        // should check if specific permissions missing
        if(result != nil)
        {
        if result.grantedPermissions.contains("email")
        {
            self.fbloginButton.enabled = false
            self.getFBUserData()
            //self.getFBUserDataWithoutEmail()
        }
        else
        {
            self.fbloginButton.enabled = false
            JLToast.makeText("Your email address has not been recovered from facebook account. Please provide it.")
            self.getFBUserDataWithoutEmail()
        }
        }
        else
        {
            JLToast.makeText("No Data.")
        }
    }
    }
    else
    {

    }
}

I am checking its logging "here" however its not going further, its closing the app.

N:B: it's opening in SafariViewController in iOS 9.

Did you follow this tutorial for ios 9?

https://developers.facebook.com/docs/ios/ios9

在此处输入图片说明

I believe this is why you have problems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM