Re: Network Information API

Hi Marcos,

On 17 January 2014 10:44, Marcos Caceres <w3c@marcosc.com> wrote:

>
>
>
> On Thursday, January 16, 2014 at 11:06 PM, Francesco Iovine wrote:
>
> > > Unfortunately we ship this under the name navigator.mozConnection
> everywhere, but on desktop we just have a default implementation returning
> infinity for bandwidth and false for metered unconditionally.
> >
> >
> > Yes, navigator.mozConnection works quite well in Firefox for Android and
> Firefox OS.
>
> Can you clarify by what you mean by "works quite well"? Do you know of any
> example applications that are making use of this API in FxOS or Android?
>
>
>
>
Yes! I have written a demo application for the Network Information API: is
a photo-sharing Web Application that enables users to take pictures and
sync them with online services. It covers the use case of synchronizing
media data (photos in this case) in order to give the user control to
whether large uploads should happen over cellular. This demo will be part
of a MDN page explaining how to optimize a Open Web App for high and low
network speeds.

Live demo: http://goo.gl/0wP7Gm
Source: soon on github, anyway the most interesting part of the demo is
inside the NetworkManager

http://www.francesco.iovine.name/mdn/net-pics/public_html/scripts/utils/NetworkManager.js

When I say that the Network Information API "works quite well" on Firefox
for Android or FxOS I mean:

   - navigator.mozConnection exists
   - navigator.mozConnection.bandwidth returns different values for wifi
   and cellular networks, so I can retrieve the type
   - navigator.mozConnection.onchange works, even if it is not fired
   immediately

I tested the demo on Firefox Beta for Android 4 and on my ZTE Open FxOS 1.1

The demo supports the current W3C Specification
(navigator.connection.bandwidth), the previous specification
(navigator.connection.type) and the hypothetical upcoming specification
(navigator.netInfo), so it works in Firefox, Android browser and BB10
browser. It also combines the Network Information APIs with the Battery
Status APIs in order to sync only when the battery is charging or fully
charged, for instance. A feedback on the demo would be much appreciated.

Hope it helps! Let me know how I can help further!

Best ;)

Francesco <https://developer.mozilla.org/en-US/profiles/franciov>

Received on Friday, 17 January 2014 13:58:20 UTC