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') }
Go to Settings -> Connections -> Location and enable if necessary. Check the "Blocked" and "Allowed" lists by tapping them.
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).
To check if geolocation has been declined with JavaScript, we can use the navigator. permissions. query method. const result = await navigator.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With