首页 > 解决方案 > Firestore 设置功能不做任何事情(React Native)

问题描述

使用 FB Login 后,我试图从 facebook 个人资料中获取一些信息,并将其存储在我在 firestore 上的用户集合中。在 facebook 成功回调中使用此代码段:

var userDict = {
              id: user.uid,
              fullname: user.displayName,
              email: user.email,
              profileURL: user.photoURL + "?type=large"
            };
            var data = {
              ...userDict,
              appIdentifier: "foodwaste"
            };
            ref
              .doc(user.uid)
              .get()
              .then(docSnapshot => {
                if (!docSnapshot.exists) {
                  this.ref.doc(user.uid).set(data);
                }
              });

我的参考是const ref = firebase.firestore().collection("users");我确定 get 函数在我取回快照时有效,然后它进入 if 语句,之后什么都没有发生,没有错误,并且数据库没有得到更新。这以前可以正常工作,我一直在试图找出为什么它突然不能正常工作了很长时间!将不胜感激任何帮助谢谢。

标签: javascriptfirebasereact-nativegoogle-cloud-firestore

解决方案


推荐阅读