Summary:
User's auth state does not persist on app restart.
My situation:
I have a blank react native app (current react native version, fresh install) and installed firebase js sdk via
react-native init firebaseTest
npm i firebase --save
in my index.ios.js file I added a auth state listener and a login function
constructor(props) {
super(props);
this.state = {};
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
console.log('user logged in: ', user);
} else {
console.log('not logged in…');
}
});
}
login() {
firebase.auth().signInWithEmailAndPassword('te...@test.com', 'test123')
.catch((error) => {
console.log('Error: ', error.message);
});
}
Login works, however if I restart, user object is null… By restart I mean closing the app on simulator and then reopen it.
Is this intended behaviour? I read (I think in this group) that user status persists.
Thanks,
Florian