Run action before sending app to background or close app

Is there a way to run an action before an Ionic Vue app is closed or send to background?

If you’re using Capacitor, you could try the appStateChange listener.

Thank you - that was the “problem” :wink: I was looking in the Ionic Documentation, not the Capacitor Documentation…

Thank you for your help!

appStateChange works for when it is sent to the background, but not for when the app is closed :confused:.
Does anyone know how to execute the action before closing the app?

I can’t conceive of any way to do what you ask. Browsers don’t give notifications when closing pages.

well, in my case the app has been compiled android with capacitor.
And I wanted to know if there was a way to get with some capacitor plugin to get the event (for example) onDestroy() of android.