【发布时间】:2022-02-21 08:30:19
【问题描述】:
我正在使用 react native 来克隆火种。
用户权限刷卡时会出现上述错误。
我正在使用 Firebase 来存储数据。
这是问题所在的代码,但不能,请帮助。
代码:
// check if the user swiped on you...
getDoc(doc(db, "users", userSwiped.id, "matches", user.uid)).then(
(documentSnapshot) => {
console.log(documentSnapshot);
if (documentSnapshot.exists()) {
// user has matched with you before you had matched with them.
// Create a MATCH
console.log(`hooray you MATCHED with ${userSwiped.displayName}`);
setDoc(
doc(db, "users", user.uid, "matches", userSwiped.id),
userSwiped
);
// storing matched users data separately
setDoc(doc(db, "matched", generateId(user.uid, userSwiped.id)), {
user: {
[user.uid]: loggedInUserProfile,
[userSwiped.id]: userSwiped
},
usersMatched: [user.uid, userSwiped.id],
timestamp: serverTimestamp()
});
navigation.navigate("Match", {
loggedInUserProfile,
userSwiped
});
}
else {
// user has swiped as first interaction between two or did not get swiped.
console.log(`you swiped on ${userSwiped.displayName}`);
setDoc(
doc(db, "users", user.uid, "matches", userSwiped.id),
userSwiped
);
}
}
);
【问题讨论】:
标签: node.js reactjs firebase react-native