ios - FIRAuth : An error has occurred while accessing the keychain (Swift 3)

标签 ios firebase firebase-authentication swift3

我在通过 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 .

最佳答案

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

关于ios - FIRAuth : An error has occurred while accessing the keychain (Swift 3),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39555289/

相关文章:

swift - Firestore - Swift 子集合

javascript - 即使在定义绑定(bind)后也无法读取未定义的属性 'setState'(this.submit)

android - 将 buildToolsVersion 更新为 '26.0.2' 后出错

java - 如何在 google 端点中验证 firebase token ?

ios - 在 iOS 4.3 中将 YpCbCr iPhone 4 相机帧渲染为 OpenGL ES 2.0 纹理

ios - 在 Firebase 中注册 ios 应用程序时如何解决未知错误?

ios - 无法推断通用参数

javascript - Firebase 身份验证和 Google 登录

reactjs - firebase 身份验证在刷新时延迟

xcode - IOS:弹出位置