【问题标题】:Xcode Swift Firebase How to create a second instance of FIRAuth [duplicate]Xcode Swift Firebase如何创建FIRAuth的第二个实例[重复]
【发布时间】:2016-10-19 06:24:52
【问题描述】:

有人知道我如何在 Swift 中创建第二个 FIRAuth 实例吗?你看,这些天你不能以编程方式创建一个新用户。然后,您将以您创建的新用户身份登录。像这样:

FIRAuth.auth()?.createUser(withEmail: txtUsername.text!, password: txtPassword.text!, completion: {
        user, error in
        //your stuff
    })

解决方法是创建 FIRAuth 的第二个实例,这实际上会在您未退出的情况下创建新用户。

SecondFIRAuth.auth()?.createUser(withEmail: txtUsername.text!, password: txtPassword.text!, completion: {
        user, error in
        //your stuff
    })

如果有一些代码建议我可以如何管理它会很棒。

【问题讨论】:

标签: swift xcode firebase firebase-authentication


【解决方案1】:

创建用户后,我认为您不需要再次创建用户。

您可以对现有用户进行身份验证,例如,

BASE_REF.authUser(email, password: password, withCompletionBlock: { (error, authData) -> Void in
                if (error == nil) {

                 // Auth success, 
                 // Do your stuff here

                } else {
                    print(error)
                }
            })

其中 BASE_REF 是 Dravidian 在评论中建议的我的 firebase 全局参考

【讨论】:

    猜你喜欢
    • 2014-06-03
    • 2019-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-27
    • 1970-01-01
    相关资源
    最近更新 更多