Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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' }) ?

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading