Location Accuracy Ionic Plugin 2

Asked

Viewed 129 times

1

I’m using an API Location Accurancy Ionic v2 follows the code:

cordova.plugins.locationAccuracy.canRequest(function(canRequest){
    if(canRequest){
        cordova.plugins.locationAccuracy.request(function (success){
            console.log("Successfully requested accuracy: "+success.message);
        }, function (error){
           console.error("Accuracy request failed: error code="+error.code+"; error message="+error.message);
           if(error.code !== cordova.plugins.locationAccuracy.ERROR_USER_DISAGREED){
               if(window.confirm("Failed to automatically set Location Mode to 'High Accuracy'. Would you like to switch to the Location Settings page and do this manually?")){
                   cordova.plugins.diagnostic.switchToLocationSettings();
               }
           }
        }, cordova.plugins.locationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY);
    }
});

The "canRequest" function always returns false and does not request to be able to activate.

  • Have you tried using this plugin by ionicNative?

1 answer

0

According to the plugin documentation , about the canRequest method:

On Android, this will Return true if the app has Authorization to use Location.

So we can assume that the method will always return false if your app doesn’t have permission to locate the user. Make sure you are asking for this permission, usually this is done in some configuration file.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.