J'ai fait une fonction qui détecte l'état du réseau et tout fonctionne bien lorsque je tester cette fonction sur le navigateur ou l'application vue ionique.Détection de réseau de Ionic 2 ne fonctionne pas correctement
Mon problème est survenu lorsque j'ai installé mon application sur mon appareil Android, j'ai éteint mon wifi mais rien ne se passe.
Voici mon code:
constructor(...){
platform.ready().then(() => {
...
this.checkConnection();
})
}
checkConnection(){
this.network.onConnect().subscribe(data => {
console.log(data);
//this.displayNetworkUpdate(data.type);
if(this.isOffline==true){
this.isOffline=false;
this.toast.dismiss();
}
}, error => console.error(error));
this.network.onDisconnect().subscribe(data => {
console.log(data)
//this.displayNetworkUpdate(data.type);
if(this.isOffline==false){
this.isOffline=true;
this.toast= this.toastCtrl.create({
message: 'No Internet connection. Make sure that Wi-Fi or Cellular mobile data is turned on, then continue using the application.',
duration: 99999999999
});
this.toast.present();
}
}, error => console.error(error));
}