title: Checking for Active Network connection and exiting the app if not active in ionic using ngCordova
body: <p>i am developing a conference app that is data driven and constantly will be updated from the web server. i am storing data on the local storage for persistence, but when the app is installed and launched for the first time i want to pop up a "No Internet Connection" message and close the app when they click any button on the pop up. but when there is internet load the app. i have done this in my app.run function but it does not work.</p>
  
  <pre><code>var app = angular.module('starter', ['ionic', 'ionic-material', 'ngCordova']);
  
  app.run(function ($ionicPlatform, $ionicPopup, $timeout) {
      $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 &amp;&amp; window.cordova.plugins.Keyboard) {
              cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
          }
          if (window.StatusBar) {
              StatusBar.styleDefault();
          }
  
          //checking for internet connection on startup
          if (window.Connection) {
              if (navigator.connection.type === Connection.NONE) {
                  document.addEventListener("offline", function () {
                      $ionicPopup.confirm({
                          title: "Internet Disconected",
                          content: "Sorry, No internet connection now, please try again"
                      }).then(function (result) {
                          if (!result) {
                              $ionicPlatform.exitApp();
                          }
                      });
                  }, false);
              }
          }
      });
  });
  </code></pre>
  
  <p>the app pops up the message, but on click of any of the buttons(ok and cancel), the app just stays on white screen. it does not exit the app.
  i don't know what am doing wrong. please i need advice and code samples to correct my error. </p>