React Native Expo 生产版本中的 Firebase 登录问题 - 在 SigninScreen 中选择 Google 帐户后崩溃

问题描述 投票:0回答:1
我在我的

React Native 应用程序中面临一个关键问题,在登录过程中选择 Google 帐户后,该应用程序突然崩溃,但仅限于生产版本。

在开发版本(Expo)中,该应用程序运行正常,没有任何问题崩溃。下次应用程序打开时,checkedSignIn 函数可以正常工作,这意味着登录成功,但不会在 firestore 中创建文档。

概述:

该问题特别发生在我的 React Native 应用程序的生产版本中。

    在登录过程中选择 Google 帐户后发生崩溃。
  • 预期的行为是完成登录过程并将 setUser() 设置为已登录的用户。
  • 该应用程序在开发版本(Expo)中运行良好,没有任何崩溃或问题。
  • 编辑[进一步记录后,代码似乎停在这一行,因为此后不再显示任何日志并且应用程序崩溃:]

const { user } = await auth().signInWithCredential(googleCredential);

相关代码: 这是我的 useAuth 挂钩中的相关代码片段:

// ...

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

    世博会:~48.0.15
  • @react-native-firebase/应用程序:^17.4.3
  • @react-native-firebase/auth:^17.4.3
  • @react-native-google-signin/google-signin:^9.0.2
  • Firebase:^9.21.0
对我来说,问题是我需要
react-native firebase-authentication expo google-signin react-native-firebase
1个回答
0
投票
并且:

转到我的

GoogleService-Info.plist
    文件
  1. 复制REVERSED_CLIENT_ID
  2. 的值
    导航到项目的目标并选择我的应用程序
  3. 选择
  4. Info
  5. 选项卡并导航至
  6. URL Types 部分 点击加号 (+) 图标将新项目添加到 URL 类型部分
  7. REVERSED_CLIENT_ID
  8. 的值粘贴到 URL 方案字段中。
  9. 如果您觉得这些说明不够清晰,您可以在
  10. 5:20

观看此视频,该视频完成了这些步骤

© www.soinside.com 2019 - 2024. All rights reserved.