Firebase数据库未存储用户信息

时间:2018-07-24 22:40:31

标签: swift firebase firebase-realtime-database

由于某种原因,没有任何东西存储到数据库中,我一直在使用相同的代码,并且在我不明白为什么现在不起作用之前,它已经起作用了

这是怎么做的:

//auth process above
                    ProgressHUD.showSuccess()
                    let when = DispatchTime.now() + 1
                    DispatchQueue.main.asyncAfter(deadline: when){
                        ProgressHUD.dismiss()
                        self.storeUserData(userId: (user?.user.uid)!) //original was (user?.uid)! but it seems that google has change it
                        KeychainWrapper.standard.set((user?.user.uid)!, forKey: "uid")
                        let TBVC = mainTabBarController()
                        self.present(TBVC, animated: true, completion: nil)
                    }
                }
            })
        }
    }

    func storeUserData(userId: String) {
        Database.database().reference().child("users").child(userId).setValue([
            "username": username.text,
            "password": password.text,
            "email": email.text
            ])
    }

1 个答案:

答案 0 :(得分:0)

我会这样完成并看到错误

let dic = [
        "username": username.text,
        "password": password.text,
        "email": email.text
        ]

Database.database().reference().child("users").child(userId).setValue(dic, withCompletionBlock: { (error, ref) in

     print(error) // check error and see
 })