ask for geolocation permission again if it was denied

rpsep2 picture rpsep2 · Dec 19, 2013 · Viewed 40.4k times · Source

im building an app through phonegap, with a geolocation button.

if a user denies permission for geolocation the first time, how can i ask for permission again when they click the geolocation button again?

my code structure at the moment is:

function getLocation() {    
    if(navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition, positionError);

    } else {
        hideLoadingDiv()
        showError('Geolocation is not supported by this device')
    }
}

function positionError() {
    hideLoadingDiv()
    showError('Geolocation is not enabled. Please enable to use this feature')
}

Answer

gtournie picture gtournie · Dec 19, 2013

You can't.

The only thing you can do is to display the instructions to reactivate the location sharing in his browser's settings (https://support.google.com/chrome/answer/142065?hl=en).