capacitor-community / barcode-scanner

A fast and efficient (QR) barcode scanner for Capacitor
MIT License
439 stars 173 forks source link

Firefox Error: Camera permissions are not available in this browser #259

Open pavva91 opened 1 year ago

pavva91 commented 1 year ago

Is your feature request related to a problem? Please describe. I managed to run the barcode-scanner on chromium-based browsers, is it planned to run the barcode-scanner also on firefox? Describe the solution you'd like A clear and concise description of what you want to happen. Run the scanner on Firefox Describe alternatives you've considered I tried alternative solutions (my stack is vue/ionic/capacitor) with no luck:

Additional context I took the code from: https://github.com/capacitor-community/barcode-scanner#usage

thegnuu commented 1 year ago

The current browser solution is in beta and not ready for production, so it is possible that this implementation has issues. We are working on a better solution for the future, but this has currently not the highest priority since we are working on other issues at the moment. I will keep the issue open and inform you about some news.

pavva91 commented 1 year ago

I looked into it and it looks like that the error is generated by this call: https://github.com/capacitor-community/barcode-scanner/blob/5a1e8d6c799ec72bc23ff15df857fa6ec5b5a6fe/src/web.ts#L98

and is related to this: https://github.com/mozilla/standards-positions/issues/19#issuecomment-370158947 Basically Firefox is not implementing query for "camera". After a quick research I found out that on firefox must use this to prompt for camera permission: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia on code should be something like that:

      const firefoxPermission = navigator.mediaDevices.getUserMedia({ video: true });

Is it possible to try a PR to fix this?

pkunszt commented 1 year ago

Just opened a PR for this. With this, firefox is also working. @pavva91