Please suggest the best way to achieve
use the below method in your app.components.ts
if (this.network.type == "none") {
this.checkNetwork("offline");
}
Observable.merge(this.network.onConnect(), this.network.onDisconnect())
.subscribe(e => this.checkNetwork(e.type), err => console.error(err));
checkNetwork(e) {
if (e == "online") {
this.loadingPopup.dismiss();
this.createLoading();
this.isOnline = true;
} else {
this.loadingPopup.present();
this.isOnline = false;
}
}
check network type hat u ll get first… if it is online then the internet is turned on else it will be offline
@yashwanth493 thanks for your precious time, will you please brief, i am new in Ionic.
Thanks a lot
in this… when u get network type is none… here none means offline the call checkNetwork() this method…
take out this outside if condition put in else part and try
window.location.onLine this is a read only variable which shows whether you are in Online/offline based on this you can implement your functionality with network connection plugin from ionic .Hope this will help