Checking network connection

angular.module('starter', ['ionic', 'starter.controllers', ''])

    .run(function($ionicPlatform) {
      $ionicPlatform.ready(function() {
        // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
        // for form inputs)
        if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
        if (window.StatusBar) {
          // org.apache.cordova.statusbar required
        if(window.Connection) {
          if(navigator.connection.type == Connection.NONE) {
                  title: "Internet Disconnected",
                  content: "The internet is disconnected on your device."
              .then(function(result) {
                  if(!result) {

I’m trying to add a check network connection to my app which checks to see if the user has available internet connection while opening the application but isn’t working. Any idea why?


Check these two useful tutorials on ionic


you have to add the cordova-plugin-network-information plugin to use this.

Than keep in mind… you can have wifi acccess but no internet access then the ConectionType is not NONE!

And i your device goes offline/online during your app is open you need to listen to the online, offline events triggered by the network-information plugin:

        document.addEventListener('online', function () {
           // is online
        }, false);
        document.addEventListener('offline', function () {
            // is offline
        }, false);


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:

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