使用未声明的类型' FirebaseAuthCrential'

时间:2017-11-28 19:00:34

标签: ios swift firebase firebase-authentication

我正在关注我要进行facebook身份验证的视频教程。

我和视频中的人完全一样,但他没有收到任何错误。

问题是我要使用FirebaseFacebookProvider和FirebaseAuthCredential。

我已经安装了所有pod并导入它们。

这是我的代码。

import UIKit
import FBSDKCoreKit
import FBSDKLoginKit
import Firebase

class LoginViewController: UIViewController{

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

    @IBAction func facebookBtnTapped(_ sender: AnyObject) {

        let facebookLogin = FBSDKLoginManager()

        facebookLogin.logIn(withReadPermissions: ["email"], from: self) { (result, error ) in
            if error != nil {
                print("JESS: Unable to authenticate with facebook - \(error)")
            }else if result?.isCancelled == true{
                print("JESS: User cancelled facebook authentication")
            }else {
                print("JESS: Successfully authenticated with facebook")
                let credential = FirebaseFacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString)
                self.firebaseAuth(credential)
            }
        }

    }

    func firebaseAuth(_ credential: FirebaseAuthCrential){
        FirebaseAuth.auth()?.signIn(with: credential, completion: { (user, error) in
            if error != nil {
                print("JESS: Unable to authenticate with facebook - \(error)")
            }else {
                print("JESS: Sucessfully authenticated with Firebase")
            }
        })

    }

1 个答案:

答案 0 :(得分:1)

您有FirebaseAuthCrential,但应该是FirebaseAuthCredential