Ionic PWA, setRoot()


I have a PWA built with Ionic. My login in with Azure AD worked earlier but now, somehow it breaks.

    if (!this.adalservice.userInfo.authenticated) {
    else {

I have tried with:



That is how my code looks, on web it works great. But on Android, in standalone mode, it does not change the root to TabsPage, it just stays on the same page (LogInPage).

Any ideas on how to fix this?

Probably not related to the navigation itself. Did you see any js error in the console?

Also note, the cache with pwa is powerful, don’t hesitate to try a couple of time to clean cache and retry :wink:

No errors logged. Yeah we tried to clear it a few times, clear & restart device. Nothing worked, but will look into the PWA & Stencil and see if i might swap over to it. :slight_smile:

1 Like

Keep us posted about your findings, good luck

ps.: not related to your issue, but you know what @enystr, I just lost 15 minutes because of I did forgot to test a nginx change with a blank new cache :smile:

Looks like Azure is not using its callback and authenticating the user.

Used a variable to see if the user was authenticated, always returns false. But it only happens when it is in PWA, browser works fine and returns true…

I remember that in order to implement a valid Facebook login with a PWA I had to remove the hashbang (#) from the URLs (= Ionic 3 routing) otherwise the return URl was wrongly interpreted, maybe that’s your problem too?

Hm, could be the case. Mind sharing some code?

In app.modules set locationStrategy to path

IonicModule.forRoot(MyApp, {
        locationStrategy: 'path'

WARNING: It may solve your problem but may result in some others, like when a user will refresh (with refresh I mean refresh action of the browser) a page which could end up in an error. I have set my nginx to redirect everything to the root which partially solve this.

NOTE: As far as I understand, due to the introduction of the new routing system in Ionic 4, this won’t be an issue anymore, I think or I hope

Sadly no improvements… Will keep looking for a solution. Its wierd because it worked fine earlier, and we havent touched the login part since…


well I’m a bit out idea too, good luck, keep posted with the solution when you will find it

So i found the missing part, i don’t know why it worked earlier and stopped worked all of a sudden. But i found out that i had been missing out on a few stuff on the AD Config.

const config = {
  instance: '', 
  tenant: '*********',
  clientId: '******************',
  popUp: false,
  redirectUri: "****************",
  cacheLocation: 'localStorage',

Using that i managed to get it to work again :) Sorry for the late reply.