我尝试通过此代码将用户添加到Firebase数据库。但是当我在我的应用程序上创建一个帐户时。没什么可推送到Firebase数据库的。请帮助我
导入UIKit 导入Firebase 导入FirebaseUI 进口FirebaseDatabase 导入FirebaseAuth
RegisterView类:UIViewController {
@IBOutlet weak var txtEmail: UITextField!
@IBOutlet weak var txtPass: UITextField!
@IBOutlet weak var txtPassConfirm: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func backBtn(_ sender: Any) {
self.dismiss(animated: true, completion: nil)
}
@IBAction func createClick(_ sender: Any) {
guard let email = txtEmail.text else {return}
guard let pass = txtPass.text else {return}
FireStoreManager().register(user: email, password: pass, complete: {(error, result) in
if error != nil {
print(error)
return
}
var ref: DatabaseReference!
ref = Database.database().reference(fromURL: "https://appchat-e2938.firebaseio.com/")
let values = ["check": "0", "email": email, "password": pass, "uid" : "", "userName" : ""]
ref.updateChildValues(values, withCompletionBlock: { (err, ref) in
if err != nil {
print(err)
return
} else {
print("Saved user in Firebase Database")
}
})
})
}