Ionic Network don't return any data or response

Ionic Network don't return any data or response

I am trying to check the internet/network connection of the device using Network Plugin but it doesn't seem to work. It didn't even return any data or error messages on the console. Here is my code.

I am trying to check the internet/network connection of the device using Network Plugin but it doesn't seem to work. It didn't even return any data or error messages on the console. Here is my code.

import { Network } from '@ionic-native/network';

@Component({ templateUrl: 'app.html' })

export class MyApp {

constructor(public platform: Platform, private splashScreen: SplashScreen, private statusBar: StatusBar public network: Network) { this.initializeApp(); }

initializeApp() { this.platform.ready().then(() => { this.statusBar.styleDefault(); this.splashScreen.hide(); this.checkInternetConnection(); } }

checkInternetConnection() { this.network.onDisconnect().subscribe(data => { console.log('network was disconnected :-('); }, error => console.log(error));

this.network.onConnect().subscribe(data => {
  console.log('network connected!');
  setTimeout(() => {
    console.log('woohoo!');
  }, 3000);
}, error => console.log(error));

} }

I hope someone can help me. Thank you in advance 😊

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Ionic 4, Angular 7 and Cordova Crop and Upload Image

The comprehensive step by step tutorial on crop, and upload Image using Ionic 4, Angular 7 and Cordova

How to Create Mobile Apps using Ionic 4, Angular 8 and Cordova?

In this Ionic 4 tutorial, we will show you how to create mobile apps quickly using Ionic 4, Angular 8, and Cordova

How to use the Cordova Camera Plugin to capture the image in Ionic App

In this Ionic 4 Cordova Camera Plugin tutorial, we'll learn how to use the Cordova camera plugin to capture the image in an Ionic 4 app. Learn how to take pictures using Ionic Native & Cordova Camera plugin. Ionic Native support is fantastic to access the native devices.