What happens to JavaScript execution (settimeout, etc.) when iPhone/Android goes to sleep?

后端 未结 4 2029
广开言路
广开言路 2020-12-13 02:25

I have a jQuery Mobile web app which targets iOS and Android devices. A component of the application is a background task, which periodically checks for a.) changes to local

4条回答
  •  青春惊慌失措
    2020-12-13 02:47

    You should use the Page Visibility API (MDN) which is supported just about everywhere. It can detect if a page or tab has become visible again and you can then resume your timeouts or carry out some actions.

提交回复
热议问题