swiftxcodefacebookfirebasefbsdkloginkit

Unable to pass Facebook User properties to Firebase FIRAuth in Swift 3


I'm using the following function to login a User with a Facebook Token and the Firebase FIRAuth function. There is no error and no print of email property. As if the function wouldn't be called.

var login = FBSDKLoginManager()

@IBOutlet weak var fbBtnPressed: UIButton!

@IBAction func fbBtnPressed(_ sender: AnyObject) {

    login.logIn(withReadPermissions: ["public_profile", "email", "user_friends"], from: self) { (FBSDKLoginManagerLoginResult, Error) in

        if Error != nil {
            print("The login with Facebook don't working. Erro: \(Error)")
        } else {
            let accessToken = FBSDKAccessToken.current().tokenString
            print("Login with Facebook ok. \(accessToken)")                

            let credential = FIRFacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString)

            FIRAuth.auth()?.signIn(with: credential) { (email, error) in

                if (error != nil) {
                    print("The login in the Firebase broke \(error)")
                } else {
                    print("Login in the Firebase ok \(email)")   
                }   
            }   
        }   
    }       
}

Solution

  • After a lot of research, it seems to be a change in Swift3 in combination with the Keychain swap.

    You have to enable the Keychange Sharing in your project under capabilities.

    enter image description here

    enter image description here