UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Facebook login Access token is nil

Forums > Swift

I integrated the connection with facebook and firebase. when I try the button in the simulator, everything is fine. but when I test it on the iPhone, I get this error message Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value

func loginButton(_ loginButton: FBLoginButton, didCompleteWith result: LoginManagerLoginResult?, error: Error?) { if let error = error { print(error.localizedDescription) return }

let current = AccessToken.current!.tokenString let credential = FacebookAuthProvider.credential(withAccessToken: current)

2      

You trying to unwrap an optional you should unwrap it safely

if let current = AccessToken.current.tokenString {
  let credential = FacebookAuthProvider.credential(withAccessToken: current)
}

2      

Thank, the connection with facebook work very well in the simulator but, he does not work when I test it with the iPhone.

2      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.