Right Now I am Using this code to check the internet connection. And it only checks when it is triggered or called:
.factory('Checkinternet', function($ionicPlatform,$ionicPopup) {
return {
isonline: function() {
if(window.Connection) {
if(navigator.connection.type == Connection.NONE){
$ionicPopup.confirm({
title: 'No Internet Connection',
content: '<span style="color:black">Sorry, no Internet connectivity detected. Please reconnect and try again.</span>'
}).then(function(result) {
if(!result) {
//ionic.Platform.exitApp();
}
});
return 'off';
}
}
}
};
})
What I want is whenever Internet goes away It should Alert (Without Using Setinterval
as it is slowing the performance of my app when it runs in background)
Is there any other way Of doing this ??