I want to check internet connection inside my app but cordova plugin is working with special versions so I started to think how can I do this? I find this code from this page How to check whether user has internet connection or not in Angular2?
export class LoginPage {
public onlineOffline: boolean = navigator.onLine;
constructor(public navCtrl: NavController, public navParams: NavParams) {
window.addEventListener('online', () => {this.onlineOffline = true});
window.addEventListener('offline', () => {this.onlineOffline = false});
}
ionViewDidLoad() {
console.log('ionViewDidLoad LoginPage');
}
}
but it seems it check only network connectivity not internet connectivity. it shows true when connected to any network regardless that network providing internet access or not.
Any kind of help is welcome.