Great to have this landed. We have a lot of app partners that will benefit from this.
An important aspect for me would be how to polyfill this to get apps to adopt it asap. The easiest way would be to use the alarm API to set the timer for the next message handler. Wifi can be detected and the request state can be stored in async/local-storage. The only open question on feasibility would be on how to programmatically trigger a message handler? /Harald On Tuesday, January 6, 2015 6:48:50 AM UTC-8, Andrea Marchesini wrote: > The main differences are: > > 1. with mozAlarms you have to specify a date, here we have an interval. > 2. with this API we are free to postpone some task in order to avoid overload > of the phone: no more than 1 task running at the same time (if it takes less > than 10 secs~). > > 3. wifiOnly tasks > > 4. the tasks can be configured by the settings app (using > navigator.syncManager). This means, for instance, that the use can decide how > often sync the mailbox. > > > b > > > > On Mon, Jan 5, 2015 at 9:14 PM, Michael Henretty <[email protected]> wrote: > > > Thanks for the heads up Baku! > > What is the advantage of using the syncAPI over mozAlarms? > > > > Thanks, > Michael > > > > > > On Mon, Jan 5, 2015 at 5:52 AM, Andrea Marchesini <[email protected]> > wrote: > > > > > > Hi all, > > I just landed RequestSync API, an API for b2g only that allows apps to > schedule tasks. > > Here the webIDL: > > https://hg.mozilla.org/integration/mozilla-inbound/file/f60d4ad64070/dom/webidl/RequestSyncScheduler.webidl > > > A simple example is this: > > > navigator.sync.register('foobar', { minInterval: 2, > oneShot: true, > data: 42, > wifiOnly: false, > wakeUpPage: location.href }).then( > function() { > ok(true, "navigator.sync.register() oneShot done"); > ... > }, genericError); > > > navigator.mozSetMessageHandler('request-sync', function(e) { > ok(true, "One event has been received!"); > is (e.task, "foobar"); > ... > }); > > > The params are: > > 1. minInterval - in seconds. It can happen that this operation will be > scheduled with a bigger interval. > > 2. oneShot - true/false, similar to setInterval/setTimeout. > > 3. data: whatever you want to pass to the message handler. > > 4. wifiOnly: if true, the task will not scheduled if wifi is not active > > 5. wakeUpPage: the page that will receive the system message. > > > > We also have a 'setting' API accessible only if the app has the > 'requestsync-manager' permission. > > This is the webIDL: > > https://hg.mozilla.org/integration/mozilla-inbound/file/f60d4ad64070/dom/webidl/RequestSyncManager.webidl > > > With this API the settings app can overwrite the policy and the minInterval > of any task of any app: > > > navigator.syncManager.registrations().then( > function(results) { > ... > results[0].setPolicy("wifiOnly", 123 /* minInterval */); > }); > > > More documentation (not up-to-date yet): https://etherpad.mozilla.org/syncAPI > > > b > > > _______________________________________________ > > dev-b2g mailing list > > [email protected] > > https://lists.mozilla.org/listinfo/dev-b2g _______________________________________________ dev-b2g mailing list [email protected] https://lists.mozilla.org/listinfo/dev-b2g
