Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use in Cordova App on iOS #271

Closed
wstrik opened this issue Jan 9, 2020 · 11 comments
Closed

Use in Cordova App on iOS #271

wstrik opened this issue Jan 9, 2020 · 11 comments

Comments

@wstrik
Copy link

wstrik commented Jan 9, 2020

In relation to #167 and #210 I'm trying to get the zxing-js library working with Cordova on iOS.
Thanks to the related issues, it is working on Android. I guess it's the same problem that was with Android. Which is it doesn't has permissions for the camera.

I have just a blank page with the plugin on it. I get the following error:
ERROR: {"line":2,"column":28352,"sourceURL":"..../zxing-umd.js"}
Which reads:
throw new Error("Can't enumerate devices, method not supported.");
As said, i think this is because of no camera permissions.

I tried installing the barcodescanner with no result.

@odahcam
Copy link
Member

odahcam commented Jan 9, 2020

Seems like camera permissions problem, have you tried using anything like this?

@wstrik
Copy link
Author

wstrik commented Jan 10, 2020

Yes, I've installed that plugin also.

So I installed and started the Barcodescanner plugin. Than it asks for the camera permission and the plugin works. After that I loaded the zxing library, but still the same error.

Also when I run navigator.mediaDevices.getUserMedia({ video: true }) it doesn't return anything.

@odahcam
Copy link
Member

odahcam commented Jan 11, 2020

As this comment says, I think maybe cordova uses some web view implementation (obviously) and because of that the WebRTC API might not be available for Cordova on iOS. That seems like the same issue we have with PWAs at this moment.

@wstrik
Copy link
Author

wstrik commented Jan 14, 2020

Hmm, thanks!

@odahcam
Copy link
Member

odahcam commented Jan 14, 2020

Have you taken a look at React Native implementations?

@wstrik
Copy link
Author

wstrik commented Jan 14, 2020

No. But I worked it out with the Cordova Barcodescanner plugin implemented in the hosted site. It only gets loaded when it's in the app. Otherswise it loads xzing.

@pj035
Copy link

pj035 commented Jul 8, 2020

We're having the same problem. It's a known limitation because of missing WebRTC support in the WkWebView (hopefully this changes soon). Anyhow, there is cordova-plugin-iosrtc, which provides an implementation of WebRTC. We tried that out and only succeeded partially. The camera loads and is visible, but the scanSuccess (nor error) event aren't triggered.

@capc0
Copy link

capc0 commented Sep 1, 2020

@wstrik can you elaborate how you worked around this limitation and scan barcodes on iOS cordova?

@ninijay
Copy link

ninijay commented Nov 18, 2020

@pj035 Did you work out how to use it together with the cordova-plugin-iosrtc to trigger the scanSuccess event? Or did you solve it in another way. Would be interested as I'm facing similar issues and haven't tried it yet

@pj035
Copy link

pj035 commented Nov 19, 2020

@ninijay I was testing this for a customer app and due to time constraints I didn't follow it any further. We are now using one of the ionic plugins to scan QR codes. They are slower, but at least we can use them (no blame on ngx-scanner, but rather on Apple).

Sorry!

@odahcam
Copy link
Member

odahcam commented Feb 9, 2021

Just as an update, latest iOS version seem to support the WebRTC API needed for this component to work. I didn't test it yet, but it's good news already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants