@OmDIonic wrote:
Hi All
For checking internet in app I implemented below code but nothing is triggeringPlugin Installation:
ionic cordova plugin add cordova-plugin-network-information
npm install @ionic-native/network
Testing Enviornment : ios simulator iphone xs 12.1 . (cant test on real device to unavailability )
Internet connection to simulator : WIFI connection in MacBookCode:
this.platform.ready().then(() => { if (this.platform.is('ios')) { // watch network for a disconnection let disconnectSubscription = this.network.onDisconnect().subscribe(() => { alert('network was disconnected :-('); }); // stop disconnect watch disconnectSubscription.unsubscribe(); // watch network for a connection let connectSubscription = this.network.onConnect().subscribe(() => { alert('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') { alert('we got a wifi connection, woohoo!'); } }, 3000); }); // stop connect watch connectSubscription.unsubscribe(); } });
Can somebody tell me my mistake?.
Thanks
Posts: 1
Participants: 1