0

I am trying to set a tutorial page for the first timers in the app and login page for others. I am setting key value in localstorage if user has been gone through the tutorial page.

export class MyApp {
rootPage: any = LoginPage;

constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
    platform.ready().then(() => {
        statusBar.styleDefault();
        if(!localStorage.getItem( 'tutorial' )) {
            this.rootPage = TutorialPage;
        }
        splashScreen.hide();
    });
  }
}

Above code is working fine but there is a delay in setting the tutorial page and Login page is viewing first then Tutorial page is coming up. I want to know that am I doing this in the right way or I am missing something?

Shubham
  • 497
  • 10
  • 23

1 Answers1

3

please use following code

export class MyApp {
rootPage: any;

constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
    platform.ready().then(() => {
        statusBar.styleDefault();
        if(!localStorage.getItem( 'tutorial' )) {
            this.rootPage = TutorialPage; // user can user this.nav.setRoot(TutorialPage);
        }else{
            this.rootPage = LoginPage; // user can user this.nav.setRoot(LoginPage);
        }
        splashScreen.hide();
    });
  }
}

i hope its work for you.

Nakul Kundaliya
  • 542
  • 2
  • 12