Just a comment - treating "wifi" as a special case is perhaps not the best 
strategy. It might be better to have "unmeteredConnectionOnly", because the 
wifi connection could be to a mobile hotspot. This would  of course require the 
user to set up wifi/bluetooth PAN/etc. connections as metered or not, but that 
can be down the line. Android had to do this recently (see 
https://developer.android.com/reference/android/net/ConnectivityManager.html#isActiveNetworkMetered%28%29)

On Monday, 5 January 2015 15:52:55 UTC+2, Andrea Marchesini  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

Reply via email to