moribvndvs / ng2-idle

Responding to idle users in Angular (not AngularJS) applications.
https://moribvndvs.github.io/ng2-idle
Apache License 2.0
315 stars 128 forks source link

onTimeout event not triggered on the "onResume" event Cordova / Ionic 2 #46

Closed dnmd closed 7 years ago

dnmd commented 7 years ago

I'm submitting a ...

[ x ] bug report => search github for a similar issue or PR before submitting
[ - ] feature request
[ - ] support request => Please do not submit support request here, instead see https://github.com/HackedByChinese/ng2-idle/blob/master/CONTRIBUTING.md#getting-help

Current behavior There are three ways to send an app to the "background" (in general). Only in the first scenario, where the hardware button is pushed, the onTimeout event is triggered correctly.

[ x ] Using the home button; works correctly [ - ] Switching to another app (double tap home button / switch app button); not working [ - ] Turning the screen off (clicking the off button shortly); not working

Expected behavior

Minimal reproduction of the problem with instructions Send an Cordova / Ionic 2 app to the background via either the second or third method.

Please tell us about your environment:

moribvndvs commented 7 years ago

I haven't used Cordova or Iconic before, so I'll need an assist on this. However, DEFAULT_INTERRUPTSOURCES is defined as this. So if you are using this, it's only looking for typical touch, mouse, and keyboard events on the document, plus storage events.

You can definitely use your own settings for interrupt sources and even create and use your own. I'm taking a shot in the dark here, but by using what's defined in DEFAULT_INTERRUPTSOURCES plus adding new WindowInterruptSource('focus refresh') (or whatever makes sense in Iconic), you can listen for those events on the window when the app comes back from the background.

dnmd commented 7 years ago

Thanks, and sorry for the late reply. After a good closer look, it seemed that the plugin was working just fine. The issue was caused due to a prompt which was presented to the user, but - with the app in the background - was unable to load.