【发布时间】:2019-06-26 09:27:33
【问题描述】:
我正在尝试将用户连接到 Firestore 中的用户集合。我正在使用云功能,但我认为我没有正确实施它。
firebase.auth().createUserWithEmailAndPassword(email, password)
.then(() => {
console.log('user created')
exports.createUserDoc = functions.auth.user().onCreate((user) => {
console.log("hi")
const userId = user.uid;
const account = {
posts: []
}
return admin.firestore().collection("Users").doc(userId).add(account)
})
但是我的 console.log(hi) 没有出现。我正确地接近这个吗?任何建议都有帮助!
【问题讨论】:
-
我认为你需要先部署你的云功能。当您创建用户时,该功能会自动触发。您没有在应用程序中实现云功能。 cloud.google.com/functions/docs/quickstart-console
-
云功能是 Node.js(服务器端)。您必须查看云功能日志才能看到任何
console.log消息。无论如何,.onAuthStateChanged是监听用户状态变化的正确方法(不是.onCreate) -
你解决了吗?我也有类似的问题。
标签: firebase react-native google-cloud-firestore