barcode-scanner icon indicating copy to clipboard operation
barcode-scanner copied to clipboard

Firefox Error: Camera permissions are not available in this browser

Open pavva91 opened this issue 2 years ago • 3 comments

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:

  • https://github.com/gruhn/vue-qrcode-reader
  • https://github.com/bitpay/cordova-plugin-qrscanner

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

pavva91 avatar Jun 07 '23 14:06 pavva91

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.

thegnuu avatar Jun 08 '23 09:06 thegnuu

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?

pavva91 avatar Jun 08 '23 11:06 pavva91

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

pkunszt avatar Aug 28 '23 10:08 pkunszt