Wake up once a minute to check for messages

If all the application windows are closed (and not merely hidden), the
background page will go inactive and there's nothing we can do to stop
it. However, we can ask chrome to trigger an alarm once per minute,
which will spin up the background page and check for new messages.

This will effectively keep us alive as long as chrome has open windows
or is running in the background, subject to chrome settings'
Advanced -> System -> Continue running background apps
This commit is contained in:
lilia 2015-05-22 17:06:49 -07:00
parent fa3e1ee94f
commit 9882190bde
2 changed files with 9 additions and 1 deletions

View file

@ -16,6 +16,13 @@
;(function() {
'use strict';
if (chrome && chrome.alarms) {
chrome.alarms.onAlarm.addListener(function() {
// nothing to do.
});
chrome.alarms.create('awake', {periodInMinutes: 1});
}
storage.fetch();
storage.onready(function() {
var messageReceiver;

View file

@ -9,7 +9,8 @@
"permissions": [
"unlimitedStorage",
"notifications",
"fileSystem"
"fileSystem",
"alarms"
],
"icons": {