Show Tutorial only when application is running for the first time


#1

Hi !
I got a little problem with my code.
I would like to show a tutorial only if the app is opened for the first time and when user goes on ‘25 foot walk’ page
Here is the code I tried:

export class Survey_25footPage {
  constructor(public navCtrl: NavController, public storage: Storage) {
    if(localStorage.getItem['firstTimeLoad']!='TRUE'){
      localStorage.setItem['firstTimeLoad']='TRUE';
      this.navCtrl.setRoot(TutorialPage); 
  }

The tutorial (because it’s in constructor ?) is called everytime and when i skip the tutorial, it shows again…

What should I do to fix that ?
Thanks a lot for your time !


#2

You’re injecting ionic-storage and then not using it. I would recommend using it and getting rid of all the references to localStorage, because they don’t make any sense. Function calls in JavaScript use (); [] is for accessing object properties and array elements.


#3

Hi, in storage there is a property ‘firstTimeLoad’ too ?