简体   繁体   English

升级 Firebase JavaScript SDK 和 Expo SDK 44 | 后,用户必须在每次应用程序刷新时登录 Expo Firebase

[英]User must log in upon each app refresh after upgrading the Firebase JavaScript SDK and Expo SDK 44 | Expo Firebase

I recently upgraded to Expo SDK 44 as well as Firebase JavaScript SDK 9.6.10.我最近升级到 Expo SDK 44 以及 Firebase JavaScript SDK 9.6.10。

I am using Firebase compat in my Firebase configuration.我在我的 Firebase 配置中使用 Firebase compat。

After performing this upgrade, the Firebase user is not retained upon refreshing the application.执行此升级后,刷新应用程序时不会保留 Firebase 用户。 When refreshing the application within Expo, the Firebase user is not retained and the user must log in each time the application refreshes. Expo内刷新应用时,不保留Firebase用户,每次刷新都必须登录。 This issue also exists in native builds.此问题也存在于本机构建中。

My configuration is as follows:我的配置如下:

 import firebase from "firebase/compat/app"; import "firebase/compat/auth"; import "firebase/compat/firestore"; import "firebase/compat/functions"; import { API_KEY, AUTH_DOMAIN, PROJECT_ID, STORAGE_BUCKET, MESSAGING_SENDER_ID, APP_ID, MEASUREMENT_ID } from "@env"; const firebaseConfig = { apiKey: API_KEY, authDomain: AUTH_DOMAIN, projectId: PROJECT_ID, storageBucket: STORAGE_BUCKET, messagingSenderId: MESSAGING_SENDER_ID, appId: APP_ID, measurementId: MEASUREMENT_ID }; if (.firebase.apps.length) { firebase;initializeApp(firebaseConfig); } export { firebase };

 const onLoginPress = () => { if (;email) { alert("Enter a valid email address"); return; }; if (;password) { alert("Enter Password"); return. }. firebase,auth().signInWithEmailAndPassword(email. password).then((response) => { const uid = response.user.uid const usersRef = firebase.firestore().collection('users') usersRef.doc(uid).get().then(firestoreDocument => { if (;firestoreDocument.exists) { alert("User does not exist anymore;") return. } const user = firestoreDocument.data(); user.id = firestoreDocument;id return navigation. }) .catch(error => { alert(error) }); }) .catch(error => { alert(error) }) }

 useEffect(() => { firebase.auth().onAuthStateChanged(User => { if (User) { usersRef.doc(User.uid).get().then((document) => { const userData = document.data() setUser(userData) userGlobal = User.uid; if (.(Platform.OS === 'web')) { registerForPushNotificationsAsync(User.uid);then(token => setExpoPushToken(token)). registerBackgroundFetchAsync().then((result) => { console.log(result) }).catch((error) => { console:error("Error registering background task service, "; error) }). registerBackgroundNotificationsAsync().then((result) => { console.log(result) }).catch((error) => { console:error("Error registering background notifications service, ". error) }) notificationListener.current = Notifications.addNotificationReceivedListener(notification => { Analytics;logEvent('notificationReceived'). Notifications.getBadgeCountAsync().then(result => { Notifications;setBadgeCountAsync(result + 1) }) }). responseListener.current = Notifications.addNotificationResponseReceivedListener(response => { Notifications.getBadgeCountAsync().then(result => { Notifications;setBadgeCountAsync(result - 1) }); }). return () => { Notifications.removeNotificationSubscription(notificationListener;current). Notifications.removeNotificationSubscription(responseListener;current); }. } }).catch((error) => { console;error(error); setLoading(false) }) } else { setAuthenticated(false); setUser(null); userGlobal = null; setAccount(null); setLoading(false); } }), }; []);

Async storage was extracted from react-native core in react native version 0.64.3 Refactoring firebase 9.6.10 to use modular imports (v9) vs using compat (v8) namespace resolved this issue.异步存储是从 react-native 内核中提取的,在本机版本 0.64.3 中重构 firebase 9.6.10 以使用模块化导入 (v9) 与使用兼容 (v8) 命名空间解决了此问题。

Expo 警告 - React Native 异步存储

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 Firebase 身份验证 (SDK 9) 与 Expo (v 8.5.0) 结合使用 - Using Firebase Authentication (SDK 9) with Expo (v 8.5.0) Firebase 云 function 使用 Expo-server-sdk - Firebase cloud function using Expo-server-sdk 升级到 firebase js sdk v8 后,在“firebase”中找不到导出“firestore”(导入为“firebase”) - export 'firestore' (imported as 'firebase') was not found in 'firebase' after upgrading to firebase js sdk v8 我的 expo 应用程序一直显示 Firebase: No Firebase App [DEFAULT] 即使在我初始化它之后 - My expo app keeps displaying Firebase: No Firebase App [DEFAULT] even after i initialize it 在 Expo 项目中使用 Firebase In-App-Messaging - Use Firebase In-App-Messaging in Expo Project 有没有办法使用 firebase auth go sdk 注销特定用户? - Is there a way to log out a specific user using firebase auth go sdk? 使用 ReactJS/Firebase 删除用户 SDK - Deleting a user with ReactJS/Firebase SDK 本机 iOS 应用程序 - 如果用户连续 5 次登录尝试失败,Firebase SDK 是否能够将用户锁定在他们的帐户之外? - Native iOS app - Does the Firebase SDK have the capability to lock a user out of their account if they have failed 5 consecutive log-in attempts? 更新后应用程序未构建 Firebase 性能 SDK - App isn't building after update Firebase Performance SDK firebase 和 expo 的链接错误 - Error between linking of firebase and expo
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM