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 😊

ionic cordova

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Pros and Cons of Ionic Development

If you think Ionic is the right cross-platform application development, here are a few pros and cons of Ionic development. 

Cordova Vs Capacitor Ionic

What is Cordova

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 Ionic Controllers in Ionic 5.x

In this video, we take a look at how Ionic's controllers work in Ionic 5. This is specific to plain JavaScript or StencilJS - other frameworks provide a wrapper for the controllers.