【问题标题】:FIRAuth: An error has occurred while accessing the keychain (Swift 3)FIRAuth:访问钥匙串时发生错误(Swift 3)
【发布时间】:2017-01-26 02:06:22
【问题描述】:

我遇到了通过 Firebase 登录的问题。 Swift 2 时一切正常,但是在 XCode 将我的整个项目转换为 Swift 3 语法后,发生了错误。

这是我的登录代码:

func loginDidFinish(_ email: String, password: String, type: LoginViewController.SendType) {

        // Server call implementation here
        if type == .login {
            FIRAuth.auth()?.signIn(withEmail: email, password: password, completion: { (user, error) in

                if error != nil {
                    self.alert = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert)
                    self.present(self.alert, animated: true, completion: nil)
                    let delay = Double(2) * Double(NSEC_PER_SEC)
                    let time = DispatchTime.now() + Double(Int64(delay)) / Double(NSEC_PER_SEC)
                    DispatchQueue.main.asyncAfter(deadline: time) { [weak self] in
                        self!.alert.dismiss(animated: true, completion: nil)
                    }
                } else {

                    _ = self.navigationController?.popViewController(animated: true)
                }
            })
        } else { // type == .SignUp
            FIRAuth.auth()?.createUser(withEmail: email, password: password, completion: { (user, error) in

                if error != nil {
                    self.alert = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert)
                    self.present(self.alert, animated: true, completion: nil)
                    let delay = Double(2) * Double(NSEC_PER_SEC)
                    let time = DispatchTime.now() + Double(Int64(delay)) / Double(NSEC_PER_SEC)
                    DispatchQueue.main.asyncAfter(deadline: time) { [weak self] in
                        self!.alert.dismiss(animated: true, completion: nil)
                    }
                } else {

                    _ = self.navigationController?.popViewController(animated: true)
                }
            })
        }

附:当我尝试注册时一切正常。用户已创建,但popUpViewController 在这里不起作用。

附言我已经看过类似的问题"An error occurred while accessing the keychain" when signing in using Firebase,但对此一无所知。另请阅读此https://firebase.google.com/docs/auth/ios/errors

【问题讨论】:

    标签: ios firebase firebase-authentication swift3


    【解决方案1】:

    解决此问题的步骤: 转到项目目标 -> 功能 -> 开启“钥匙串共享”

    【讨论】:

      猜你喜欢
      • 2020-06-20
      • 1970-01-01
      • 2011-03-11
      • 2021-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多