Checking Internet network and exiting the app on first startup

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 function but it does not work.

var app = angular.module('starter', ['ionic', 'ionic-material', 'ngCordova']); ($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 && window.cordova.plugins.Keyboard) {
        if (window.StatusBar) {

        //checking for internet connection on startup
        if (window.Connection) {
            if (navigator.connection.type === Connection.NONE) {
                document.addEventListener("offline", function () {
                        title: "Internet Disconected",
                        content: "Sorry, No internet connection now, please try again"
                    }).then(function (result) {
                        if (!result) {
                }, false);

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.

Have you managed to solve this ?