Ionic 5 angular ...how to skip loginpage using guard and how to fire up the device

38 Views Asked by At

i have a project in ionic 5 . after successful login and close the app after again opening the app shows a 1 sec login page and then redirect to routed page ,which my case is home how to prevent it from showing the page using guard

i have done these and getting device fireup issue

route page

path: '',
canActivate:[LoginGuard],
children:[
  
]

LoginGuard page

  public async canActivate(
    route: ActivatedRouteSnapshot,
    state: RouterStateSnapshot): Promise<any> {
      let res = await this.storage.get('loggedIn');
      console.log(res)
      if (res == null) res = 0
      if(res == 0){
        return this.route.parseUrl('/login');
      }else if (res == 1) {
        return this.route.parseUrl('/home');
      }
      
  }
1

There are 1 best solutions below

0
shahid On

I removed/commented out:

path: '',
canActivate:[LoginGuard],
children:[]

And added authentication check and redirection in app.components.ts as I did in ionic 3... Which works I guess for now.