Re: Network Information API

Hi Marcos,

On 17 January 2014 10:44, Marcos Caceres <> 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:
Source: soon on github, anyway the most interesting part of the demo is
inside the NetworkManager

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

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 <>

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