expo react native: firebase.auth().onAuthStateChanged is not called

Viewed 173

I've been looked at numerous similar questions on stack-overflow and/or GitHub but none of the solutions offered have solved my problem. As it is stated in the title, the onAuthStateChanged handler is not called.

I have a Sign up form where user create an account by providing (among other things) his email and password. Then I signup the user with firebase:

firebase.auth().createUserWithEmailAndPassword(user.email, user.password)

But later on, when I reload the application, onAuthStateChanged is never called and firebase.auth().currentUser returns null;

Here is my code (simplified):

  useEffect(() => {
    setAuthenticated(true);
    const unsubscribe = firebase.auth().onAuthStateChanged((user) => { // <-- this is not called
      if (user) {
        // user is connected
      }
    });
    return unsubscribe;
  }, []);

Also in firebase console: Authentication --> Sign-in method --> Authorized domain, I have added my domains (including localhost).

This code used to work until yesterday...

0 Answers
Related