2014-07-22 24 views
0

我目前正在嘗試爲我的應用程序設置後臺服務,以便在打開電話時打開應用程序。如果我沒有弄錯,如果webapp的清單中包含「background_page」,那麼後臺服務應該會自動運行,而不會打開應用程序。目前後臺服務未運行。Firefox OS:後臺服務,清單選項「background_page」不起作用

清單

{ 
    "version": "1.0", 
    "name": "Hello World", 
    "description": "Hello World", 
    "orientation":"portrait-primary", 
    "icons": { 
    "16": "/icons/icon_16.png", 
    "32": "/icons/icon_32.png", 
    "48": "/icons/icon_48.png", 
    "128": "/icons/icon_128.png" 
    }, 

    "permissions":{ 
    "background":{}, 
    "backgroundservice":{}, 
    "desktop-notification":{}, 
    "webapps-manage":{} 
    }, 

    "launch_path": "/index.html", 
    "background_page":"/background.html", 

    "developer": { 
    "name": "Charlie Hudson" 
    }, 
    "default_locale": "en" 
} 

背景

<!DOCTYPE html> 
<html> 
    <script> 
     navigator.mozApps.mgtm.getSelf().launch(); 
    </script> 
</html> 

回答

0

至於我可以告訴background_page是在2012年左右用於促進此行爲的屬性,但它1.0之前已經退役出來。至少我找不到任何引用它了。雖然我沒有確鑿的證據。無論如何,有幾件事你可以做,以創建此行爲:

  1. Push notifications並做同步那裏。但它確實取決於數據
  2. Alarms。您可以每分鐘安排一次鬧鐘,當應用程序被操作系統殺死時,它會通過警報API活躍回來。缺點是如果你錯過了鬧鐘(因爲手機關機),操作系統將會把它扔掉。所以安排他們很多:p

有沒有適當的方式來實現這種行爲afaik。

還要注意,當不作爲前端進程運行時,對傳感器的訪問是有限的。