SOLVED: Routing on app open best practices & patterns


#1

Hello ionic community.

I’m currently porting a large codebase from ionic 1 to ionic 3

On app open, I have to route to different pages based on conditions from firebase.

What are the best practices and patterns here?

Answer here: https://stackoverflow.com/a/46665591/2333802


#2

On SO was posted:

You should put your code on app.component.ts. An example:

const authObserver = this.afAuth.authState.subscribe(user => {
    if (user) {
        this.rootPage = 'HomePage';
        authObserver.unsubscribe();
    } else {
        this.rootPage = 'LoginPage';
        authObserver.unsubscribe();
    }
});