Saturday, August 12, 2023

How to check Network Status in Ionic capacitor ?

 


NPM install




Step 1 : npm install @capacitor/network 

Step 2 :   

 import { Network } from '@capacitor/network

 constructor() {

    this.checkNetworkConnection();

  }

checkNetworkConnection(){

  Network.addListener('networkStatusChange', status => {

  console.log('Network status changed', status);

});

const logCurrentNetworkStatus = async () => {

  const status = await Network.getStatus();

  console.log('Network status:', status);

};

}


No comments:

Post a Comment

How to build an Express and Node.js app with Typescript

  In this tutorial, you will learn how to set up a Node.js and Express project with Typescript and live auto-reloading. Note that this metho...