Firebase,Facebook登录AccessToken未找到

时间:2019-05-02 16:17:32

标签: swift facebook firebase firebase-authentication

我正在尝试在我的应用程序中唱歌,但是在点击按钮后登录我的应用程序时崩溃,并且在包装AccesToken.current中的Optional时出现错误意外地发现nil。我已经在firebase中正确设置了Facebook身份验证,并且将FB文档中的代码添加到了InfoPlist中。 我的AppDelegate

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    FirebaseApp.configure()
    SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
    GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID
    GIDSignIn.sharedInstance().delegate = self

   UIApplication.shared.statusBarStyle = .lightContent

    return true
}

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool{
    return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
}

登录VC中的按钮

@IBAction func facebookTapped(_ sender: UIButton) {

    let credential = FacebookAuthProvider.credential(withAccessToken: AccessToken.current!.authenticationToken)
    Auth.auth().signInAndRetrieveData(with: credential) { (user, error) in
        if let error = error{
            print(error)
            return
        }
        print("logged")
    }

} 

我应该在哪里寻找错误?或者我该如何解决?

0 个答案:

没有答案