For starters, it seems as if oneShot allows apps that want to be woken up at a regular interval to not have to continually add alarms to mozAlarms. The wifiOnly option is useful too (say you're calendar or email and have a setting to periodic sync <> wifi is available).
On Mon, Jan 5, 2015 at 3:30 PM, Jan Varga <[email protected]> wrote: > I guess, better battery life ? > > > On 05/01/15 21:14, Michael Henretty 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 > [email protected]https://lists.mozilla.org/listinfo/dev-b2g > > > > _______________________________________________ > dev-b2g mailing list > [email protected] > https://lists.mozilla.org/listinfo/dev-b2g > > -- Best, Gareth
_______________________________________________ dev-b2g mailing list [email protected] https://lists.mozilla.org/listinfo/dev-b2g
