【问题标题】:Error adding Firebase users Swift添加 Firebase 用户 Swift 时出错
【发布时间】:2016-06-28 14:58:03
【问题描述】:

根据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)")
                    }
    })

编辑

传播的错误是:

错误代码:AUTHENTICATION_DISABLED) 项目创建于 console.firebase.google.com 必须使用新的 Firebase 身份验证 可从 firebase.google.com/docs/auth/ 获得的 SDK

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

【问题讨论】:

  • 调试它并查看error 对象。它应该包含有关错误的更多详细信息。
  • 您使用的是什么firebase 版本?
  • 我不完全确定我使用的是哪个版本的 firebase,但我相信是最新的。
  • 您的代码似乎是 Firebase 2.x,但控制台是与 Firebase 3.x 关联的新代码

标签: ios swift firebase firebase-authentication


【解决方案1】:

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

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

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

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

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

【讨论】:

    猜你喜欢
    • 2017-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-25
    • 1970-01-01
    • 2015-06-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多