Network SOLVED

I was facing problems with Ionic native network plugin and this is the solution, Hope this can help you :wink:

first install

$ ionic cordova plugin add cordova-plugin-network-information
$ npm install --save @ionic-native/network

second add in your module app

third and then in your page

import { Network } from ‘@ionic-native/network’;

constructor(private network: Network) { }

displayNetworkUpdate(connectionState: string){
let networkType = this.Network.type

this.toast.create({
  message: `Ahora estas ${connectionState }`,
  duration: 3000,
  position: 'bottom'
}).present();

}

//funcion que verificar constantemente conecion de internet
ionViewDidLoad() {
this.connected = this.Network.onConnect().subscribe(data => {
this.displayNetworkUpdate(data.type);
}, error => console.error(error));
this.disconnected = this.Network.onDisconnect().subscribe(data => {
this.displayNetworkUpdate(data.type);
}, error => console.error(error));
}