@ionic-native/network

  • Version 5.36.0
  • Published
  • 29.4 kB
  • 1 dependency
  • MIT license

Install

npm i @ionic-native/network
yarn add @ionic-native/network
pnpm add @ionic-native/network

Overview

Ionic Native - Native plugins for ionic apps

Index

Variables

variable Network

const Network: NetworkOriginal;

    Classes

    class NetworkOriginal

    class NetworkOriginal extends IonicNativePlugin {}
    • Network network-information Requires Cordova plugin: cordova-plugin-network-information. For more info, please see the [Network plugin docs](https://github.com/apache/cordova-plugin-network-information).

      import { Network } from '@ionic-native/network/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();

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

    property Connection

    Connection: {
    UNKNOWN: string;
    ETHERNET: string;
    WIFI: string;
    CELL_2G: string;
    CELL_3G: string;
    CELL_4G: string;
    CELL: string;
    NONE: string;
    };
    • Constants for possible connection types

    property downlinkMax

    downlinkMax: string;
    • Downlink Max Speed {string}

    property type

    type: string;
    • Connection type {string}

    method onChange

    onChange: () => Observable<'connected' | 'disconnected'>;
    • Returns an observable to watch connection changes {Observable<'connected' | 'disconnected'>}

    method onConnect

    onConnect: () => Observable<any>;
    • Get notified when the device goes online

      Returns

      {Observable} Returns an observable.

    method onDisconnect

    onDisconnect: () => Observable<any>;
    • Get notified when the device goes offline

      Returns

      {Observable} Returns an observable.

    Enums

    enum Connection

    enum Connection {
    UNKNOWN = 'unknown',
    ETHERNET = 'ethernet',
    WIFI = 'wifi',
    CELL_2G = '2g',
    CELL_3G = '3g',
    CELL_4G = '4g',
    CELL = 'cellular',
    NONE = 'none',
    }

      member CELL

      CELL = 'cellular'

        member CELL_2G

        CELL_2G = '2g'

          member CELL_3G

          CELL_3G = '3g'

            member CELL_4G

            CELL_4G = '4g'

              member ETHERNET

              ETHERNET = 'ethernet'

                member NONE

                NONE = 'none'

                  member UNKNOWN

                  UNKNOWN = 'unknown'

                    member WIFI

                    WIFI = 'wifi'

                      Package Files (1)

                      Dependencies (1)

                      Dev Dependencies (0)

                      No dev dependencies.

                      Peer Dependencies (2)

                      Badge

                      To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                      You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@ionic-native/network.

                      • Markdown
                        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@ionic-native/network)
                      • HTML
                        <a href="https://www.jsdocs.io/package/@ionic-native/network"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>