i want to execute an specific function when the device has an Internet connection.
I try this:
checkConnection(API){
this.network.onConnect().subscribe(() => {
this.changeAPI(API);
});
this.network.onDisconnect().subscribe(() =>{
let loading = this.loadingCtrl.create({
content: 'No Connection'
});
loading.present();
setTimeout(() => {
loading.dismiss();
}, 1500);
});
}
But its doesnt work, so how i can check the connection?