Firefox OS App (timer) Background Execution

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?


    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.


    你有没有试过使用Worker API?

    链接地址: http://www.djcxy.com/p/79752.html

    上一篇: 触摸键盘外部时禁用Firefox OS键盘自动隐藏

    下一篇: Firefox OS应用程序(定时器)后台执行