小编Luk*_*ter的帖子

Expo Firebase 身份验证持久性未按预期工作

我有一个firebaseConfig.js看起来像这样的:

import { initializeApp } from "firebase/app";
import { initializeAuth } from "firebase/auth";
import { getReactNativePersistence } from "firebase/auth/react-native";
import { AsyncStorage } from "@react-native-async-storage/async-storage";
import { getFirestore } from "firebase/firestore";

const firebaseConfig = {...};

export const app = initializeApp(firebaseConfig);

const authState = initializeAuth(app, {
  persistence: getReactNativePersistence(AsyncStorage)
});

export const auth = authState;

export const db = getFirestore(app);
Run Code Online (Sandbox Code Playgroud)

然后,当我登录用户时,它看起来像这样:

import { auth } from "../../firebaseConfig";
...
 signInWithEmailAndPassword(auth, email.trim(), password)
  .then(() => {
     // Handle success.
  })
Run Code Online (Sandbox Code Playgroud)

然后在 App.js …

javascript firebase react-native firebase-authentication expo

5
推荐指数
1
解决办法
947
查看次数