Ionic V6 - App doesn't return to starting page after living in background

I’ve migrated an app from Ionic v4 to v6. It has various Capacitor and Cordova dependencies, and uses Angular 14 now. All seems to be well except for one issue. The basic flow is user logs in/auths with JWT to a server and stores a token. Then app goes to it’s main page. User does their thing and maybe leaves the app for a couple days. Prior to migration, when I would open the app back up, it would go back to the login page in which case would validate the token and proceed. That all used to work as expected. However, now the app just stays at whatever page it was on when the user left the app (sitting in the background for a day let’s say). Everything is fine if it’s just a couple hours but leave it for a day and the data is gone. At that point all of the local data has disappeared and the constructor for that particular page seems to be called again. The page has no data cached and shows more or less blank (because all the data is in storage, grabbed from services, or passed into the page under normal circumstances).

Example: I leave the app on PageC and open it the next day. It needs the data passed from PageB (think detailed view of PageB) to display but it’s not there. What should happen is a full reload back to Login.

/Login → /MainPage → /PageB → /PageC

What causes an Ionic app to restart versus maintain some sort of state in the background? I could post code but don’t know what to, before any commentary. The routing is very basic all preloaded. Is there something new in Angular that’s missing?

I wonder if you are seeing something similar (ish) to what I’m seeing with certain devices Difference between normal iOS app startup and O/S forced startup?

And also:

Hmmm…sure sounds in the same ballpark!

is your issue similar to this?

Similar but the reverse I suppose. I want the app to “die out” after a while so the app can go through its automatic auth steps. Otherwise there’s a chance the user is going to try and push data with an invalid token, which I have hooks for but would rather avoid in the normal flow.

I just looked quick and I interestingly enough show android:launchMode=“singleTask” on this app. That said, I haven’t even gotten to testing this leave it a long time issue on Android, this appears on iOS for sure though.

Are you seeing your issue on all devices right now? With the current issue I have, I only seem to be seeing it in one of my test devices - an iPhone SE. On my iPhone 11 I’m not seeing it. Admittedly our issues may be different even though they are similar

maybe it depends on the OS version?

Just following up on this…it definitely does. This only is happening on iOS (current version anyway). It doesn’t happen on Android at all that I can see.

We’re having the same problem. Data is gone, navigation stack is gone ( back button disappears ) but application stays on the same page - practically breaking the application.

1 Like

Have you traced it down to being OS specific?

Identical issue here. App migrated from Ionic V2 Cordova to V6 Capacitor. After app has been in the background for a day or so App comes back to screen BACK button is gone, data gone nav stack gone.

So far, have only seen this on iOS

I can’t even find a good way to simulate this. Tried the various sleep options available to dev but none act the same.

Anyone figure this out?

esxmarkc, still haven’t figured anything out. I’ve tabled it for now. One interesting note, I use Bitwarden for password management and have noticed that their iOS app does the same thing quite often. If you leave it on the detail screen for a password, switch apps and pull it back up some time later, the app loses context of where it is and I have to force kill it too.