概述:
该问题特别发生在我的 React Native 应用程序的生产版本中。
const { user } = await auth().signInWithCredential(googleCredential);
// ...
const signInWithGoogle = async () => {
try {
setLoading(true);
await GoogleSignin.hasPlayServices({ showPlayServicesUpdateDialog: true });
const { idToken } = await GoogleSignin.signIn();
const googleCredential = auth.GoogleAuthProvider.credential(idToken);
const { user } = await auth().signInWithCredential(googleCredential);
await setUserInFirestore(user);
} catch (error) {
setError(error);
console.log("Error signing in with Google:", error);
}
};
// ...
const setUserInFirestore = async (user) => {
const { uid, displayName, email, photoURL } = user;
try {
const userRef = doc(db, "users", uid);
const snapshot = await getDoc(userRef);
if (!snapshot.exists()) {
await setDoc(userRef, {
displayName,
email,
photoURL,
uid,
subscription: null,
});
}
setUser(user);
setUserContext(user);
} catch (error) {
console.log("Error adding user to Firestore:", error.message);
navigation.navigate(routes.WELCOME);
} finally {
setLoading(false);
}
};
版本:
反应本机:0.71.8
转到我的
GoogleService-Info.plistREVERSED_CLIENT_ID
导航到项目的目标并选择我的应用程序
REVERSED_CLIENT_ID
观看此视频,该视频完成了这些步骤