Cordova.Diganostic.IsLocationEnabled always returns true


#1

As title says, whether location is turned off or on success callback is always triggered. Anyone got any suggestions?

if (window.cordova) {
    window.cordova.plugins.diagnostic.isLocationEnabled(locationEnabled,locationDisabled );
}
function locationEnabled() {.. }
function locationDisabled() {...}

I’m testing it on Samsung galaxy s5 with lolipop


#2

Hello neshke89. Sorry, I’m late. I found you because I had the same problem and I realized that the success callback is always triggered because the diagnostic worked, not because the GPS is enabled or not. You are not getting the correct GPS status because you need to declare a parameter on locationEnabled method.

if (window.cordova) {
    window.cordova.plugins.diagnostic.isLocationEnabled(locationEnabled,locationDisabled );
}

function locationEnabled(status) {.. }
function locationDisabled(error) {...}

status will return true if GPS is enabled and false otherwise.