How can i detect in Ionic Vue if the app closes or if the app is send to the background?
this.platform
or platform
isn't available or does not work?!
You can subscribe to the appStateChange
event, like described here: https://capacitorjs.com/docs/apis/app
Example:
import { App } from '@capacitor/app'
export default {
created () {
App.addListener('appStateChange', state => {
if (!state.isActive) { // if isActive is true, App got sent to foreground, if it is false, it got sent to the background
...
}
})
}
}