0

How to check if browser supports navigator.permissions.query({ name: 'microphone' }) ?

Firefox has error when using the above code:

Uncaught (in promise) TypeError: 'microphone' (value of 'name' member of PermissionDescriptor) is not a valid value for enumeration PermissionName.

But surprizingly when you log this code in firefox you get "function" !!!:

typeof navigator.permissions.query 

How to check if browser supports navigator.permissions.query({ name: 'microphone' }) ?

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Sara Ree
  • 3,417
  • 12
  • 48

1 Answers1

2

It returns a promise, you can try using catch.

i.e.:

navigator.permissions.query({ name: 'microphone' }).catch(e => console.log("i'm catching the error"))

You can also await and use try/catch approach.

This question may help

Alexander Santos
  • 1,458
  • 11
  • 22