Skip to main content

Network Information

EOL Notice

Network Information will reach its end-of-life on July 1, 2024, and will no longer receive updates or support. Please see Support Policy for additional information.

The Network Information plugin provides access to network data on a device, such as connection type or when the device comes online or offline.

Installation

If you have not already setup Ionic Enterprise in your app, follow the one-time setup steps.

Next, install the plugin:

npm install @ionic-enterprise/network-information
npx cap sync

Index

Enumerations

Classes


Enumerations

Connection

Connection:

CELL

CELL: = 6


CELL_2G

CELL_2G: = 3


CELL_3G

CELL_3G: = 4


CELL_4G

CELL_4G: = 5


ETHERNET

ETHERNET: = 1


NONE

NONE: = 7


UNKNOWN

UNKNOWN: = 0


WIFI

WIFI: = 2



Classes

Network

Network:

name: Network

description:

usage:

import { Network } from '@ionic-enterprise/network-information/ngx';

constructor(private network: Network) { }

...

// watch network for a disconnection
let disconnectSubscription = this.network.onDisconnect().subscribe(() => {
console.log('network was disconnected :-(');
});

// stop disconnect watch
disconnectSubscription.unsubscribe();

// watch network for a connection
let connectSubscription = this.network.onConnect().subscribe(() => {
console.log('network connected!');
// We just got a connection but we need to wait briefly
// before we determine the connection type. Might need to wait.
// prior to doing any api requests as well.
setTimeout(() => {
if (this.network.type === 'wifi') {
console.log('we got a wifi connection, woohoo!');
}
}, 3000);
});

// stop connect watch
connectSubscription.unsubscribe();

advanced: The type property will return one of the following connection types: unknown, ethernet, wifi, 2g, 3g, 4g, cellular, none

Connection

● Connection: object

Constants for possible connection types

Type declaration

CELL: string

CELL_2G: string

CELL_3G: string

CELL_4G: string

ETHERNET: string

NONE: string

UNKNOWN: string

WIFI: string


downlinkMax

● downlinkMax: string

Downlink Max Speed

returns:


type

● type: string

Connection type

returns:


onChange

onChange(): Observable<any>

Returns an observable to watch connection changes

Returns: Observable<any>


onConnect

onConnect(): Observable<any>

Get notified when the device goes online

Returns: Observable<any> Returns an observable.


onDisconnect

onDisconnect(): Observable<any>

Get notified when the device goes offline

Returns: Observable<any> Returns an observable.



Release Notes

2.0.2 (Jun 19, 2019)

  • fix(android): Fix bug [cordova-plugin-network-information] connection info is not reliable on Android 6 (#74) (db0d4b5, 9a45d63, 60ab69f, acc02f2, 0869800, 394452a, cafdd67)
  • chore(release): fix repo and issue link (9ec1e21)
  • docs: remove outdated translations (24e50f8)
  • build: add .npmignore to remove unneeded files from npm package (d31e135)
  • build: add .gitattributes to force LF (instead of possible CRLF on Windows) (f35341e)
  • ci(travis): Update Travis CI configuration for new paramedic (#89) (102f757)
  • ci(travis): add android-28 (27b0e39)
  • ci: drop Node.js v4 support (#87) (5158556)
  • chore(github): Add or update GitHub pull request and issue template (0cd2771)
  • docs: remove JIRA link (0796cf9)
  • ci: also accept terms for android sdk android-27 (2cde33a)
  • ci(travis): CB-13757: Add build-tools-26.0.2 to travis (5b0933d, e816db4)
  • chore: Fix release notes (#61) (629a6ab)

2.0.1 (Dec 27, 2017)

  • CB-13708 Fix to allow 2.0.0 version install (#60)

2.0.0 (Dec 15, 2017)

1.3.4 (Nov 06, 2017)

  • CB-12751 (ios) Fix connection type when airplane mode is on
  • CB-13299 (CI) Fix Android builds
  • CB-12895 added eslint and removed jshint
  • CB-13028 (CI) Browser builds on Travis and AppVeyor
  • CB-12847 added bugs entry to package.json.

1.3.3 (Apr 27, 2017)

  • CB-12622 Add Android 6.0 build badge to README
  • CB-12685 added package.json to tests folder

1.3.2 (Feb 28, 2017)

  • CB-12369 Add plugin typings from DefinitelyTyped
  • CB-12363 Added build badges for iOS 9.3 and iOS 10.0
  • CB-11838 iOS: Unregister callback function at the right timing.
  • CB-12230 Removed Windows 8.1 build badges

1.3.1 (Dec 07, 2016)

  • CB-12224 Updated version and RELEASENOTES.md for release 1.3.1
  • CB-11230 CB-11505 iOS: Add compatibility with IPv6
  • CB-11917 - Remove pull request template checklist item: "iCLA has been submitted…"
  • CB-11832 Incremented plugin version.

1.3.0 (Sep 08, 2016)

  • CB-11795 Add 'protective' entry to cordovaDependencies
  • CB-11734 Network Plugin uses Android Log class and not Cordova LOG class
  • CB-11300 (android) Recognize 2G, 3G and 4G network connection subtype names
  • Update NetworkManager.java
  • Detection of Ethernet Network Type on Android
  • fixed two potential memory leaks when doing Analyze on iOS 9
  • CB-11384 android: Does not pass sonarqube scan
  • Add badges for paramedic builds on Jenkins
  • Add pull request template.
  • Readme: Add fenced code blocks with langauage hints
  • CB-10996 Adding front matter to README.md

1.2.1 (Apr 15, 2016)

  • CB-10763 Remove emoji in cordova-plugin-network-information
  • CB-10636 Add JSHint for plugins

1.2.0 (Jan 15, 2016)

  • Adding CoreTelephony to plugin.xml
  • Adding notification for CT radio information
  • Adding CT radio information
  • CB-10160 Fixed the case mismatch issue

1.1.0 (Nov 18, 2015)

  • CB-10035 Updated RELEASENOTES to be newest to oldest
  • Fixing contribute link.
  • These notifications are objects so their address always evaluates to true.
  • Update NetworkManager.java
  • CB-9542 Browser Proxy not defined correctly
  • Solved toLowerCase issue with Locale.US

1.0.1 (Jun 17, 2015)

  • Adding .ratignore file.
  • CB-9128 cordova-plugin-network-information documentation translation: cordova-plugin-network-information
  • fix npm md issue

1.0.0 (Apr 15, 2015)

  • CB-8746 gave plugin major version bump
  • CB-8683 changed plugin-id to pacakge-name
  • CB-8653 properly updated translated docs to use new id
  • CB-8653 updated translated docs to use new id
  • CB-8185 Fixes typo in cordova.platformId
  • Use TRAVIS_BUILD_DIR, install paramedic by npm
  • CB-8185 Use navigator.onLine as connection information source on browser platform
  • CB-8653 Updated Readme
  • CB-8659: ios: 4.0.x Compatibility: Remove use of initWebView method
  • CB-8573 Integrate TravisCI
  • CB-8438 cordova-plugin-network-information documentation translation: cordova-plugin-network-information
  • CB-8538 Added package.json file

0.2.15 (Feb 04, 2015)

  • CB-8384 Network status change support on Windows
  • CB-8384 Fixes the way we detect online status on Windows
  • CB-8384 Add Windows platform quirks
  • CB-8384 Add Windows section to Network Information plugin

0.2.14 (Dec 02, 2014)

  • CB-7976 Android: Use webView's context rather than Activity's context for intent receiver
  • CB-7700 cordova-plugin-network-information documentation translation: cordova-plugin-network-information

0.2.13 (Oct 03, 2014)

  • CB-7595: Android L changes the type from Mobile to Cellular, I'm pretty sure this isn't documented

0.2.12 (Sep 17, 2014)

  • CB-7471 cordova-plugin-network-information documentation translation
  • Fix network information type exception on fxos 2
  • Added support for the browser
  • CB-6724 added documentation for manual tests
  • remove reference to test assets, they are optional
  • Renamed test dir and added nested plugin.xml
  • CB-6964 ported manual tests
  • Port network tests to plugin-test-framework
  • Fix naviagtor typo

0.2.11 (Aug 06, 2014)

  • FFOS update NetworkProxy.js
  • CB-6127 Updated translations for docs
  • CB-7019 Updated version and RELEASENOTES.md for release 0.2.10
  • Fixed docs for online/offline event being backwards

0.2.10 (Jun 24, 2014)

  • CB-6907: [android] Don't crash on startup if no networks available

0.2.9 (Jun 05, 2014)

  • updated notice file to include missing license
  • Cached extra info to better detect changes.
  • CB-6809 Add license to CONTRIBUTING.md
  • CB-6491 add CONTRIBUTING.md
  • CB-6350 - Fix networkStatusForFlags return value type to work with 64-bit iOS (closes #8)
  • Initial version of firefox os network information plugin
  • there was an error in the object definition

0.2.8 (Apr 17, 2014)

  • CB-6342: [iOS] iOS reports a cellular connection even when in Airplane mode
  • CB-6422: [windows8] use cordova/exec/proxy
  • CB-6460: Update license headers
  • CB-6465: Add license headers to Tizen code
  • Add NOTICE file

0.2.7 (Feb 05, 2014)

  • Initial implementation of Tizen plugin.

0.2.6 (Jan 02, 2014)

  • CB-5658 Add doc/index.md for netinfo plugin

0.2.5 (Dec 4, 2013)

  • [ubuntu] specify policy_group
  • add ubuntu platform
  • Added amazon-fireos platform. Change to use amazon-fireos as the platform if user agent string contains 'cordova-amazon-fireos'

0.2.4 (Oct 28, 2013)

  • CB-5128: add repo + issue tag to plugin.xml for network information plugin
  • CB-4915 Incremented plugin version on dev branch.

0.2.3 (Sept 25, 2013)

  • CB-4889 bumping&resetting version
  • [windows8] commandProxy was moved
  • CB-4889 renaming org.apache.cordova.core.network-information to org.apache.cordova.network-information
  • removed duplicate comment line from plugin.xml
  • added Network APIs for FirefoxOS
  • Rename CHANGELOG.md -> RELEASENOTES.md
  • CB-4752 Incremented plugin version on dev branch.

0.2.1 (Sept 5, 2013)