Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ask for geolocation permission again if it was denied

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') } 
like image 564
rpsep2 Avatar asked Dec 19 '13 10:12

rpsep2


People also ask

How do I fix user denied request for geolocation?

Go to Settings -> Connections -> Location and enable if necessary. Check the "Blocked" and "Allowed" lists by tapping them.

How do I ask for permission for geolocation?

The Geolocation. getCurrentPosition() function is then run, which prompts the user for permission; it runs the revealPosition() function if permission is granted (which shows the map), or the positionDenied() function if permission is denied (which makes the "Enable Geolocation" button appear).

Is there a way to check if geolocation has been declined with JavaScript?

To check if geolocation has been declined with JavaScript, we can use the navigator. permissions. query method. const result = await navigator.


1 Answers

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).

like image 79
gtournie Avatar answered Oct 11 '22 12:10

gtournie