Closed bmfay closed 6 years ago
You can use navigator.permissions.query to check state before actioning your geoLocation() call. Would be nice for this feature to be baked in though with it's own API functions.
navigator.permissions.query({name: 'geolocation'}).then((result) => {
console.log(result);
if (result.state === 'granted') {
console.log('Permission ' + result.state);
}
else if (result.state === 'prompt') {
console.log('Permission ' + result.state);
this.send('checkinEnable');
}
else if (result.state === 'denied') {
console.log('Permission ' + result.state);
}
result.onchange = function() {
console.log('Permission ' + result.state);
};
});
Thanks @ezy. For unrelated reasons we no longer need geolocation in our app, but that looks like it will do the trick if I need this behavior in the future. Thanks!
Does this service expose any way to see whether the user has blocked the geo location? As far as I can tell, the promise just never resolves. I'd like to be able to provide a UX where we can display a message to our users explaining that the feature they are trying to use will not work if they block geolocation. Thanks.