Put The below code in app.js
$rootScope.openPopup = false;
var myPopup = "";
$rootScope.showPopup = function() {
$rootScope.data = {};
// An elaborate, custom popup
myPopup = $ionicPopup.show({
template: 'Your are not connected to internet',
title: 'Connection Error',
scope: $rootScope,
buttons: [{
text: 'Exit',
onTap: function(e) {
$rootScope.openPopup = false;
ionic.Platform.exitApp();
}
},
{
text: '<b>Retry</b>',
type: 'button-positive',
onTap: function(e) {
myPopup.close();
}
}
]
});
myPopup.then(function(res) {
console.log('Tapped!', res);
});
};
var checkIsConnected = function() {
if (navigator.onLine) {
myPopup.close();
clearInterval(checkIsConnected);
$rootScope.openPopup = false;
}
}
setInterval(function() {
console.log("Is the browser online? " + navigator.onLine);
if (!navigator.onLine && $rootScope.openPopup == false) {
$rootScope.openPopup = true;
$rootScope.showPopup();
setInterval(checkIsConnected, 500);
}
}, 5000);
$rootScope.openPopup = false;
var myPopup = "";
$rootScope.showPopup = function() {
$rootScope.data = {};
// An elaborate, custom popup
myPopup = $ionicPopup.show({
template: 'Your are not connected to internet',
title: 'Connection Error',
scope: $rootScope,
buttons: [{
text: 'Exit',
onTap: function(e) {
$rootScope.openPopup = false;
ionic.Platform.exitApp();
}
},
{
text: '<b>Retry</b>',
type: 'button-positive',
onTap: function(e) {
myPopup.close();
}
}
]
});
myPopup.then(function(res) {
console.log('Tapped!', res);
});
};
var checkIsConnected = function() {
if (navigator.onLine) {
myPopup.close();
clearInterval(checkIsConnected);
$rootScope.openPopup = false;
}
}
setInterval(function() {
console.log("Is the browser online? " + navigator.onLine);
if (!navigator.onLine && $rootScope.openPopup == false) {
$rootScope.openPopup = true;
$rootScope.showPopup();
setInterval(checkIsConnected, 500);
}
}, 5000);
0 comments:
Post a Comment