1

i've update the expo sdk to v48 and since that my Firebase Auth is no longer persistent in Expo Go. If i understand correct, i have to use initializeApp and initializeApp instead of getAuth in Expo SDK > v48. But i did not get this working, maybe someone give me a hint!?

I use getAuth() in "many" other files to (on each js where i query data from firebase) is it necessary to change the Auth on all Files?

ConfigFirebase.js:

import * as firebase from 'firebase/app';

const firebaseConfig = {
  apiKey: "xxx",
  authDomain: "xxx",
  projectId: "xxx",
  storageBucket: "xxx",
  messagingSenderId: "xxx",
  appId: "xxx",
  databaseURL: "xxx",
  measurementId: "xxx"
};

firebase.initializeApp(firebaseConfig);

App.js:

import React, {useState, useEffect, useMemo} from 'react';
import './src/config/ConfigFirebase';
import { getAuth, onAuthStateChanged } from 'firebase/auth';
import AsyncStorage from '@react-native-async-storage/async-storage';


const App = () => {

  const auth = getAuth();


  const [isLogged, setIsLogged] = useState(false);

 
  useEffect(() => {

    async function checkUser() {
      
      onAuthStateChanged(auth, (user) => {
        if(user !== null) {

          Purchases.setAttributes({"email": user.email, "displayName": user.displayName });

          setIsLogged(true);
          setLoaded(true);
    
        } else {
          setIsLogged(false);
          setLoaded(true);

        }
      })
    }
  
    checkUser();
  
  }, []);

  // Rest of code....

  if (loaded) {
    return (
      <View/>
      //Return Code
      );
  }

  };

  export default App;

0 Answers0