Best Way to Check Network


#1

Ok so my app is dependent on pulling data from the server. I want to be able to show a message (no matter what page) when the network connection is no longer available. Anyone have any code or suggestions on this?


#2

You can use Cordova’s network information plugin. It’s really easy to check the current network status in combination with ngCordova’s network service $cordovaNetwork:

// Listen for offline event
$rootScope.$on('$cordovaNetwork:offline', function(event, networkState){
  // Show your offline message
})

#3

As @ohh2ahh said, you can use the cordova network plugin. I actually wrote a step by step tutorial on how to create an application that uses this plugin, and you can take a look at it here: http://www.nikola-breznjak.com/blog/codeproject/check-network-information-change-with-ionic-famework/.

Please let me know if it will prove to be helpful to you.