添加 Firebase 用户时出错 Swift
Error adding Firebase users Swift
根据 this link 上的信息,我目前正在尝试使用 Firebase 创建用户,如下面的代码所示。但是,当应用程序 运行 时,似乎没有创建用户。非常感谢任何输入。 Firebase URL 取自我的测试数据库。
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 控制台中启用了 email/password 身份验证。
如截图所示,您已经授权邮箱注册。所以问题在 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
// ...
}
根据 this link 上的信息,我目前正在尝试使用 Firebase 创建用户,如下面的代码所示。但是,当应用程序 运行 时,似乎没有创建用户。非常感谢任何输入。 Firebase URL 取自我的测试数据库。
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 控制台中启用了 email/password 身份验证。
如截图所示,您已经授权邮箱注册。所以问题在 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
// ...
}