Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android native browser does not trigger any event on device sleep #30

Closed
dorukeker opened this issue Mar 25, 2016 · 2 comments
Closed

Comments

@dorukeker
Copy link

Hello,

Very nice library. Thanks for putting it together.
My use case is for mobile devices. I want the JS fire events up on:

  • Browser app close (home button press)
  • Open a new tab in the browser
  • Device put to sleep (sleep button press)

On iOS Safari and Android Chrome all works well. I receive correct blur events for each case.
But on Android native browser (for older devices e.g. Samsung S4 etc.) device sleep does not fire any event.

Any ideas? Suggestions?
Cheers,
Doruk

Ps. In my use case I try to detect these events and kill a socket connection manually. This is why I need the device sleep as well.

@serkanyersen
Copy link
Owner

serkanyersen commented Nov 10, 2016

Hi Doruk,

it's probably way too late for this response but I'll try to answer anyways. ifvisible works on top of browser provided visibility api. As you can see on caniuse.com browser support is limited in some cases. for older Android browsers it says to use webkit prefix and ifvisible already does this.

Plus ifvisible has a polyfill in place for older browsers, but it piggybacks on top of page blur, page focus events and those are only available on desktop browsers I think.

So if it's not working on the native browser, it's quite possible that the browser does not trigger these events on device sleep. And to my current knowledge, there is not much option to get that working.

Sorry :/

@dorukeker
Copy link
Author

Hi Serkan,
Indeed it was some time ago. No worries :)
Ifvisible.js solved many of the use cases on iOS and Android. For those browsers that does not work properly, I implemented a timer logic.

I used Tock.js for that. So if the user is away for a certain time it triggers an event. And you can build your application logic around this.

Thanks for the library and thanks for the reply.
Cheers,
Doruk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants