Sorry about the red box, but we really need you to update your browser. Read this excellent article if you're wondering why we are no longer supporting this browser version. Go to Browse Happy for browser suggestions and how to update.

This plugin provides an implementation of an old version of the
Network Information API.
It provides information about the device's cellular and
wifi connection, and whether the device has an internet connection.

API Change

Until Cordova 2.3.0, the Connection object was accessed via
navigator.network.connection, after which it was changed to
navigator.connection to match the W3C specification. It's still
available at its original location, but is deprecated and will
eventually be removed.

iOS Quirks

iOS can't detect the type of cellular network connection.

navigator.connection.type is set to Connection.CELL for all cellular data.

Windows Phone Quirks

When running in the emulator, always detects navigator.connection.type as Connection.UNKNOWN.

Windows Phone can't detect the type of cellular network connection.

navigator.connection.type is set to Connection.CELL for all cellular data.

Tizen Quirks

Tizen can only detect a WiFi or cellular connection.

navigator.connection.type is set to Connection.CELL_2G for all cellular data.

Firefox OS Quirks

Firefox OS can't detect the type of cellular network connection.

navigator.connection.type is set to Connection.CELL for all cellular data.

Network-related Events

offline

The event fires when an application goes offline, and the device is
not connected to the Internet.

document.addEventListener("offline", yourCallbackFunction, false);

Details

The offline event fires when a previously connected device loses a
network connection so that an application can no longer access the
Internet. It relies on the same information as the Connection API,
and fires when the value of connection.type becomes NONE.

Applications typically should use document.addEventListener to
attach an event listener once the deviceready event fires.

Quick Example

iOS Quirks

During initial startup, the first offline event (if applicable) takes at least a second to fire.

Windows Phone 7 Quirks

When running in the Emulator, the connection.status is always unknown, so this event does not fire.

Windows Phone 8 Quirks

The Emulator reports the connection type as Cellular, which does not change, so the event does not fire.

online

This event fires when an application goes online, and the device
becomes connected to the Internet.

document.addEventListener("online", yourCallbackFunction, false);

Details

The online event fires when a previously unconnected device receives
a network connection to allow an application access to the Internet.
It relies on the same information as the Connection API,
and fires when the connection.type changes from NONE to any other
value.

Applications typically should use document.addEventListener to
attach an event listener once the deviceready event fires.