[EDITED] - I did it in Ionic 3 for Voce. Do it in your app.componentts.
I’m using Ionic 4, in my file app-routing.module.ts I use in Route Guard to check if the user has any information saved in the Path location, if I redirect to the home or if I don’t have it I send it to login. Follow the logic.
import { Component, ViewChild } from '@angular/core';
import { Platform, Nav, ToastController } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { SharedData } from '../providers/shared-data';
import { ClientStorage } from '../database/client-storage';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage: any;
constructor(
public platform: Platform,
public statusBar: StatusBar,
public splashScreen: SplashScreen,
public sharedData: SharedData,
private clientStorage: ClientStorage,
) {
this.clientStorage.buscaRealizada.then(() => {
statusBar.styleDefault();
splashScreen.hide();
if (this.clientStorage.data.UserId)
this.rootPage = 'HomePage';
else
this.rootPage = 'LoginPage';
});
});
}
}
You can take a look at the documentation: https://angular.io/guide/router#Milestone-5-route-Guards
– Eduardo Vargas
But this is applicable in Ionic?
– veroneseComS
Because supposedly Ionic has no routes...
– veroneseComS