小编Seb*_*ina的帖子

如何在 React Native/ 上保留 Firebase 用户身份验证

我已经尝试让它发挥作用有一段时间了。我使用 Expo 构建了我的应用程序,其中很大一部分是允许用户离线时使用该应用程序。这应该工作的方式是每当我打开应用程序时,我就会被带到屏幕上Login。从这里,一个useEffect钩子将确定用户是否登录,如果登录,它将重定向到该Home页面。这在用户在线时有效,但由于某种原因,每当我构建应用程序并在 iPhone 上关闭它(完全关闭它),然后在打开飞行模式并断开 Wi-Fi 的情况下重新打开时,我都会卡在屏幕Login上我无法做任何事情,因为我没有任何联系。


这是我的firebase.js

// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
// import { getAuth, initializeAuth } from "firebase/auth";
import {
  getReactNativePersistence,
  initializeAuth,
} from "firebase/auth/react-native";
import { getFirestore, enableIndexedDbPersistence } from "firebase/firestore";

import AsyncStorage from "@react-native-async-storage/async-storage";

const firebaseConfig = {...};

// Initialize Firebase

const app = initializeApp(firebaseConfig);

export const db = getFirestore(app);

export const auth …
Run Code Online (Sandbox Code Playgroud)

firebase reactjs react-native firebase-authentication expo

7
推荐指数
1
解决办法
4254
查看次数