On Mon, Jan 5, 2015 at 3:16 PM, Kevin Grandon <[email protected]> wrote: > So now the other question, is there any advantage of using mozAlarms over > sync? Should mozAlarm usage be deprecated?
If you're building a calendar or alarm clock app which needs to take an action at a given wall-clock time, then user mozAlarms. We're going to end up with a few APIs which allows applications to take actions in response to different "things" happening. For example: * Use mozAlarms if you want something to happen at a given wall-clock time. * Use RequestSync if you want something to happen at a good data-sync opportunity. * Use Geolocation v2 API if you want something to happen when the user into a given geographical area. * Use DeviceStorage v2 API if you want something to happen when a file is added to or removed from SD card. While it would be technically possible to create a super generic "register for notification" API, I don't think that that will make for an API that's easier to use than having separate function names for separate types of notifications. / Jonas > Best, > Kevin > > On Mon, Jan 5, 2015 at 3:08 PM, Jonas Sicking <[email protected]> wrote: >> >> On Mon, Jan 5, 2015 at 12:14 PM, Michael Henretty <[email protected]> >> wrote: >> > Thanks for the heads up Baku! >> > >> > What is the advantage of using the syncAPI over mozAlarms? >> >> It means that we can avoid sending the system message if the user is >> not currently online. And that we can send the message more quickly >> once the user goes offline. >> >> Eventually we can also add UI to the settings app which enables >> configuring which apps will do background sync, how often they will do >> it, and which apps should only be synced on wifi. >> >> We can also build features like "top up" which allows the message to >> be sent to all apps *right now*. Which is useful for syncing all your >> apps before getting on an airplane. >> >> In short: Because we know what the callback is specifically for data >> synchronization, we can fire it more or less often based on user >> preferences as well as device connectivity. >> >> / Jonas >> >> > 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 >> > >> _______________________________________________ >> 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
