This worked fine until today, don't know does it have something with new release of Ionic or something else. This is what i have:
$ionicPlatform.ready(function() {
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
$ionicPlatform.on('pause', function(){
alert("pause");
$rootScope.$broadcast('app-pause', {});
$rootScope.$emit('app-pause', {});
})
$ionicPlatform.on('resume', function(){
alert("resume");
})
$ionicPlatform.on('online', function(){
alert("online");
})
$ionicPlatform.$on('offline', function(){
alert("offline");
})
});
None of these events work anymore. I have updated Cordova and Ionic but also added network-information plugin but nothing.
Any suggestions?
You can try not wrapping it inside the platform ready event, the following is working for me on Android with version 1.3.0. Sitting inside app run.
$ionicPlatform.on("resume", function(){
setTimeout(function() {
alert('doc resume 5');
}, 0);
});
Try to use cordova way doing this
var exampleApp = angular.module('example', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
document.addEventListener("resume", function() {
console.log("The application is resuming from the background");
}, false);
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With