Updated on 12. July 2022 by Jan Bunk
The app triggers a couple of events on certain occasions. In this guide we'll go over which events exist and how you can listen to them.
You can listen to the events like most other JavaScript events. Simply add an EventListener to the document element and the function will be triggered when the event occurrs.
<script>
document.addEventListener("appPaused", function (e) {
console.log("The app was paused!");
});
</script>
appPaused
Called when the user exits the app, e.g. by pressing the home button or turning off their device's screen.
Other causes that fire this event:
appResumed
The opposite of appPaused
. Called when the user comes back into the app, e.g. by re-opening it (after having closed it) or by unlocking their device.
Other causes that fire this event:
customTabClosed
Fired when a custom tab gets closed. Check out our detailed guide all about why and how to open and close custom tabs here.