I have a query about ionic with capacitor v3. I would like to be able to restart the app at a specific time when the app is in the background, example: I have my app open but then I start using other applications and so 5 to 10 minutes elapse, when I reopen my app I want it to be show the splash screen and reload the current data. This does not currently happen, I can leave the app in the background for about 20 minutes and when I open it again I have the same page and the same products with the same stock. I don't know if this has to do with the life cycle of the app as it happens in Flutter. Thanks a lot.
CodePudding user response:
You cannot restart it, but you can detect when app is in the background or in the foreground and then write the logic where you want (for example, navigate to home page and refresh data).
this.platform.pause.subscribe(async () => {
//write your logic here when app goes to background
});
this.platform.resume.subscribe(async () => {
//write your logic here when app is brought to foreground
});