Firefox OS App (timer) Background Execution

青春壹個敷衍的年華 提交于 2019-12-25 09:32:16

问题


I'm developing a Pomodoro Timer app for Firefox OS and I'm having a problem with the execution of it: Once the timer is running the execution is suspended every time the phone goes in low power mode (which is quite typical in my scenario, for the timer runs for 25mins) and is resumed only when the screen is turned on again.

I searched for a way to prevent this, and according to Mozilla docs there are two APIs (Power Management and Idle) by which you could either:

  • Prevent the screen from turning off
  • Be notified when the app goes in low power mode

Unfortunately these APIs are available only for certified apps (the ones shipped with the phone), which basically means you can't use them if you want to publish your app.

Is any of you having the same problem or have a hint on how to solve this?


回答1:


Privileged apps can use navigator.requestWakeLock.

navigator.requestWakeLock("cpu");

App will never suspend even if the screen is turned off.

Background services API is better, but not implemented yet.




回答2:


have you tried to use Worker API ?



来源:https://stackoverflow.com/questions/21284418/firefox-os-app-timer-background-execution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!