Search docs/

Network Information

v2.0.1

Contents

インストール

最初に(一度限りの) セットアップ手順を実行したら, プラグインをインストールします。

Cordova:ionic cordova plugin add @ionic-enterprise/network-information Capacitor: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:


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