My app is routing to the page based on the condition but the login page appears briefly before routing users to the profile page. How can I prevent that?
initializeApp() {
firebase.initializeApp(firebaseConfig);
this.platform.ready().then(() => {
const unsubscribe = firebase.auth().onAuthStateChanged( user => {
if (!user) {
this.router.navigateByUrl('login');
unsubscribe();
console.log('if !user', user);
} else {
this.router.navigateByUrl('profile');
unsubscribe();
console.log('if user', user);
}
});
this.statusBar.styleDefault();
this.splashScreen.hide();
});
}