Plugin Location Accuracy Ionic 2

0

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.

    
asked by anonymous 01.10.2017 / 23:14

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 does not have permission to find the user . Make sure you are asking for this permission, usually this is done in some configuration file.

    
20.02.2018 / 20:39