I am trying to use the Permissions API: https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query Which should be supported by Firefox. (I am currently using Firefox Developer Edition 66.0b14).
I have a page where I initially check user permissions. Something like;
if (navigator.permissions) {
navigator.permissions.query({ name: 'geolocation' }).then(result => {
if (result.state === 'granted') {
this.getCurrentPosition()
} else if (result.state === 'prompt') {
this.getCurrentPosition()
console.log('Permissions requested. Waiting for user input...')
} else if (result.state === 'denied') {
this.locationError = true
}
result.onchange = event => {
if (event.target.state === 'granted') {
this.locationError = false
this.getCurrentPosition()
console.log('Thanks for letting us know...')
} else if (event.target.state === 'denied') {
this.locationError = true
}
}
})
}
Now this works all fine in Chrome for example. (Btw: I use this.locationError to show some info window saying that the app will only work with location services enabled)
Anyway, if I open it in Firefox I get the prompt as expected:
Now If I check the box «Remember this decision» and send either Allow/Block, I see that the onchange
is executed as expected, giving me the possibility to react onto the users decision.
BUT, if I don't check this box, and just deny or allow once, the onchange is not called, leaving me in the unknown of what actually happened. Also this the state remains being 'prompt'.
I also tried to set an interval to check Permissions again after some time, but again it would just open the prompt asking for the permission. The state never updates or changes from 'prompt' to 'denied' or 'granted'.
Is there something I am missing, or is this a Firefox bug.
Thanks for any hints
Cheers