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');
}
}
2
Answers
Fixed
just removed/commented
and added athentication check and redirection in app.components.ts....as i done in ionic 3....which works i guess for now
Just a wild guess, but could you try the below code?