Swift Firebase数据库未存储用户信息

Swift Firebase数据库未存储用户信息,swift,firebase,firebase-realtime-database,Swift,Firebase,Firebase Realtime Database,由于某种原因,数据库中没有存储任何东西,我一直在使用相同的代码,它在以前工作过,我不明白为什么它现在不工作 这就是我们一直在做的事情: //auth process above ProgressHUD.showSuccess() let when = DispatchTime.now() + 1 DispatchQueue.main.asyncAfter(deadline: w

由于某种原因,数据库中没有存储任何东西,我一直在使用相同的代码,它在以前工作过,我不明白为什么它现在不工作

这就是我们一直在做的事情:

//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
            ])
    }

我会像这样完成,以查看错误

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
 })

你建立数据库了吗?您现在需要这样做(但过去没有,Firebase最近改变了这一点)。如果您有一个新项目,您需要在写入数据库或存储之前设置规则等。我发现我的权限被拒绝了