Search docs/
Getting StartedPlugins

Network

Requires Cordova plugin: cordova-plugin-network-information. For more info, please see the Network plugin docs.

https://github.com/apache/cordova-plugin-network-information

Premier Version Available

Featuring regular release cycles, security and bug fixes, and guaranteed SLAs.

Available here

インストール

ionic cordova plugin add cordova-plugin-network-informationnpm install @ionic-native/networknpm install cordova-plugin-network-informationnpm install @ionic-native/networkionic cap sync
Ionic Native Enterprise はIonic Teamが完全にサポートしメンテナンスしているプラグインを利用できます。 詳しくみる か、エンタープライズプラグインに興味があれば 連絡ください

サポートしているプラットフォーム

  • Amazon Fire OS
  • Android
  • Browser
  • iOS
  • Windows

利用方法

Using React?

See here.

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();