Hi OutSystems friends,
To determine how much time an OutSystems Mobile App was closed, before opened again (sleep / to background / appswitch), I would like to have some sort of OnBeforeClose action in my app to set a timestamp. So I can calculate the time an OutSystems App was "sleeping".Is there an eventlistener / cordova plugin for this?Or maybe one of you guys had a different approach/solution to a simular problem?
Regards,Jasper
Hi Jasper,
You can use the pause event.
For example, in the OnReady of the BottomBar insert there a Javascript statement with this:
document.addEventListener("pause", onPause, false); function onPause() { $actions.<yourclientaction>(); }
This will run the <yourclientaction> when you exit from your application. In that <yourclientaction> you can insert in local storage a timestamp to know when it went to sleep. Then in the OnApplicationResume client action get that value to compute the amount of time the application was sleeping.
Cheers,
José
Thanks José,
I tried exactly the same this afternoon (placed in Layout block) and it wouldn't work at all.After repeating your steps it actually did work!Regards,Jasper
Hello,
I’m revisiting this topic because I have the same requirement.
However, not all of my screens have a bottom bar.
I need to execute this JavaScript once across all flows and screens so that the action runs every time the app is closed or sent to the background.
How can i make a global listener?