Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

Window.Connection not working in app.run

$
0
0

@Vageesan wrote:

Hi,
I am using Ionic CLI 1.7.14 and cordova 5.4.1, I am trying check if the device has internet access.
But it is not working and routes to default page. Earlier it was working but after updating ionic, ngCordova it stopped working. Is there any toher fix other than rolling back to older version.

The following is the code I use:

app.run(function($ionicPlatform, $ionicPopup, $cordovaNetwork, $cordovaDevice, $rootScope) {
$ionicPlatform.ready(function() {
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
StatusBar.styleDefault();
}

// Not working
if(window.Connection) {
if(navigator.connection.type == Connection.NONE) {
$ionicPopup.alert({
title: "No Internet Connection",
content: "Sorry, no Internet connectivity detected. Please reconnect and try again."
})
.then(function(result) {
ionic.Platform.exitApp();
if(!result) {
ionic.Platform.exitApp();
}
});
}
}
});
});

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>