【问题标题】:Swift Firebase says internal error when creating a new userSwift Firebase 在创建新用户时说内部错误
【发布时间】:2018-02-06 10:05:49
【问题描述】:

我正在尝试使用 Firebase 创建新用户,但它给了我消息“发生了内部错误,请打印并检查错误详细信息以获取更多信息。”我也在 Firebase 上启用了电子邮件密码身份验证。

这是我作为测试编写的所有代码,但仍然无法正常工作。

import UIKit
import Firebase

class ViewController: UIViewController {

@IBOutlet weak var emailTextField: UITextField!
@IBOutlet weak var pwordTxtField: UITextField!
@IBOutlet weak var continuebutton: UIButton!

override func viewDidLoad() {
    super.viewDidLoad()
}



@IBAction func button(_ sender: Any) {

    let email = emailTextField.text
    let password = pwordTextField.text

    Auth.auth().createUser(withEmail: email! , password: password!, completion: { (user, error) in

        if let error = error {
            print(error.localizedDescription)
        }

        else {

            print("Success")
        }
    })
}




}

我做错了什么。

谢谢!

【问题讨论】:

  • 你确定你已经安装了 pod 'Firebase/Auth' 代码是正确的吗?不是空的,第三次重新连接你的网点
  • 你是否在appdelegate上添加了plist并配置了firbaseapp。
  • 是的,我有 plist,我在 appdelegate 上配置了 firebaseapp

标签: ios swift firebase firebase-authentication


【解决方案1】:

在您的 Podfile 中包含以下 pod:

pod 'Firebase/Auth'

打开身份验证部分并启用电子邮件/密码登录方法并保存。 确保您在项目中添加了 GoogleService-Info.plist 文件。

在 Appdelegate 中:-

import Firebase

 func application(_ application: UIApplication, 
didFinishLaunchingWithOptions launchOptions: 
 [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    FirebaseApp.configure()

    return true
}

在视图控制器中:-

 import UIKit
 import Firebase

class ViewController: UIViewController {

@IBOutlet weak var emailTextField: UITextField!
@IBOutlet weak var pwordTxtField: UITextField!
@IBOutlet weak var continuebutton: UIButton!

 override func viewDidLoad() {
 super.viewDidLoad()
 }



  @IBAction func button(_ sender: Any) {

   let email = emailTextField.text
  let password = pwordTextField.text

Auth.auth().createUser(withEmail: email! , password: password!, 
 completion: { (user, error) in

    if let error = error {
        print(error.localizedDescription)
    }

    else {

        print("Success")
    }
})
 }




}

【讨论】:

  • 我有 plist,我还在谷歌网站上启用了身份验证,但它没有/不起作用
  • 我刚刚更换了 plist 并且它起作用了。非常感谢哈哈
  • 如果您的问题得到解决,请接受我的回答。
猜你喜欢
  • 1970-01-01
  • 2020-12-31
  • 2017-03-21
  • 2018-08-19
  • 2016-08-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-25
相关资源
最近更新 更多