Network Information

v2.0.1

Contents

Installation

In order to use Ionic Enterprise Edition plugins you should make sure you're using the Ionic Enterprise Cordova CLI as the regular version can have issues with scoped plugins.

npm uninstall -g cordova npm install -g @ionic-enterprise/cordova

Once you've installed the Ionic Enterprise Cordova CLI you can install the plugin.

ionic enterprise register --key=YOURPRODUCTKEY ionic cordova plugin add @ionic-enterprise/network-information

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:


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.


onchange

onchange(): Observable<any>

Returns an observable to watch connection changes

Returns: Observable<any>



Other Versions