gpt4 book ai didi

ios - 添加 Firebase 用户 Swift 时出错

转载 作者:可可西里 更新时间:2023-11-01 01:35:36 25 4
gpt4 key购买 nike

通过关注 this link 上的信息,我目前正在尝试使用 Firebase 创建用户,如下面的代码所示。但是,应用程序运行时似乎没有创建用户。非常感谢任何输入。 Firebase URL 取 self 的测试数据库。

let ref = Firebase(url: "https://test-96df2.firebaseio.com")
ref.createUser("bobtony@example.com", password: "correcthorsebatterystaple",
withValueCompletionBlock: { error, result in
if error != nil {
// There was an error creating the account
print("error creating account")
} else {
let uid = result["uid"] as? String
print("Successfully created user account with uid: \(uid)")
}
})

编辑:

传播的错误是:

Error Code: AUTHENTICATION_DISABLED) Projects created at console.firebase.google.com must use the new Firebase Authentication SDKs available from firebase.google.com/docs/auth/

但是,如下所示,在 Firebase 控制台中启用了电子邮件/密码身份验证。 enter image description here

最佳答案

正如我在您的屏幕截图中看到的那样,您已经授权了电子邮件注册。所以问题不会在 AUTHENTICATION_DISABLED 上出现。

从您的错误消息和代码片段中我可以看出您已经创建了一个新项目,但您正在尝试使用旧版 firebase SDK,因此您将遇到兼容性问题。此外,您正在查看旧的 firebase 文档。

首先,您需要确保已按照 new firebase start guide 中的说明配置项目.

之后可以看一下documentation for creating a new user使用新的 SDK。您可以在下面找到 3.x 创建用户调用。

FIRAuth.auth()?.createUserWithEmail(email, password: password) { (user, error) in
// ...
}

关于ios - 添加 Firebase 用户 Swift 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38079684/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com