I am using ionicv1, that uses angularjs,I am using this listener:
I'm adding this listener in a controller
document.addEventListener ("resume", function(){
getStatusGPS()
}, false);
function getStatusGPS(){
cordova.plugins.diagnostic.isLocationEnabled(
function(gps){
alert(gps)
if(gps){
onRequestSuccess();
}
else{
if (ionic.Platform.isIOS()) {
ionicpopup.generate("Advertencia", "Debes activar la geolocalización desde los ajustes de tu dispositivo para utilizar este servicio",null,"fn_llamarGpsIos",$scope)
}
else{
cordova.plugins.locationAccuracy.request(onRequestSuccess, onRequestFailure, cordova.plugins.locationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY);
}
}
},function(error){
console.log(error)
})
If I put this event of this way, not works for me:
document.addEventListener("resume",getStatusGPS(), false);
when I leave the view I try to eliminate it.
$scope.$on('$destroy', function() {
document.removeEventListener ("resume", function(){
getStatusGPS()
}, false);
})
but when I exit the application and re-enter any controller, the method assigned to it is executed. how can I solve that?