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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for other types of barcodes? #132

Open
HugoHeneault opened this issue Nov 21, 2017 · 11 comments

Comments

@HugoHeneault
Copy link

@HugoHeneault HugoHeneault commented Nov 21, 2017

As you provide a really nice way of scanning QR code and keep the view behind the webview, it would be awesome that you support barcodes too 馃憤

There is an issue opened on the barcode scanner to use the same thing as you did but they doesn't seem to manage it as of now... phonegap/phonegap-plugin-barcodescanner#223

@RafaelKr

This comment has been minimized.

Copy link

@RafaelKr RafaelKr commented Dec 24, 2017

+1 for this.

The underlying plugins (ZXing and AVFoundation) used by this cordova plugin are all supporting many types of barcodes, so this could be "easily" implemented for Android, iOS and Windows Phone, only the browser platform wouldn't support it. I privateley forked this and built in this functionality for my current project for Android, but it's not ready to publish yet and I don't know, if I'll publish it ever.

@HugoHeneault

This comment has been minimized.

Copy link
Author

@HugoHeneault HugoHeneault commented Dec 29, 2017

Actually, it's already working. You'll have to edit the plugins files manually, but it's worth it :)

Here's what you need to change:

iOS

platforms/ios/{{YOUR_APP_NAME}}/Plugins/cordova-plugin-qrscanner/QRScanner.swift

metaOutput!.metadataObjectTypes = [AVMetadataObjectTypeQRCode] 

by

metaOutput!.metadataObjectTypes = [AVMetadataObjectTypeEAN13Code, AVMetadataObjectTypeCode128Code] 

And

if found.type == AVMetadataObjectTypeQRCode || && found.stringValue != nil {

by

if (found.type == AVMetadataObjectTypeQRCode || found.type == AVMetadataObjectTypeEAN13Code) {{ OR WHATEVER CODES YOU NEED }} && found.stringValue != nil {

Android

just add it in the formatList array of platforms/android/src/com/bitpay/cordova/qrscanner/QRScanner.java

ArrayList<BarcodeFormat> formatList = new ArrayList<BarcodeFormat>(); 
                formatList.add(BarcodeFormat.EAN_13); 
                formatList.add(BarcodeFormat.CODE_128); 

This should be more documented, though... :)

@HugoHeneault HugoHeneault changed the title Scan barcodes Add documentation for scanning more barcodes Dec 29, 2017
@sonicwong

This comment has been minimized.

Copy link

@sonicwong sonicwong commented Jan 17, 2018

@HugoHeneault

Original code in platforms/ios/{{YOUR_APP_NAME}}/Plugins/cordova-plugin-qrscanner/QRScanner.swift should be:

metaOutput!.metadataObjectTypes = [AVMetadataObjectTypeQRCode]


And ONE MORE LINE need to change in IOS

if found.type == AVMetadataObjectTypeQRCode || && found.stringValue != nil {

change into

if (found.type == AVMetadataObjectTypeQRCode || found.type == AVMetadataObjectTypeEAN13Code) && found.stringValue != nil {

@HugoHeneault

This comment has been minimized.

Copy link
Author

@HugoHeneault HugoHeneault commented Jan 17, 2018

@sonicwong Thanks a lot for your updates. I edited my post. 馃嵒

@omkarkhalipe

This comment has been minimized.

Copy link

@omkarkhalipe omkarkhalipe commented Mar 12, 2018

how about in browser? where can I add this for browser?

@bitjson

This comment has been minimized.

Copy link
Contributor

@bitjson bitjson commented May 17, 2018

Hi all, while the focus of the plugin will remain QR codes, PRs are certainly welcome to add other types. 馃殌

As mentioned above, the native platforms basically support other codes already, we're just not enabling them.

The browser version will require quite a bit more work, though, and would likely cause a performance hit. I'd be open to PRs there though, too.

@bitjson bitjson changed the title Add documentation for scanning more barcodes Add support for other types of barcodes? May 17, 2018
@omkarkhalipe

This comment has been minimized.

Copy link

@omkarkhalipe omkarkhalipe commented May 18, 2018

In browser, I used quagga.js.
In your plugin for browser, you just had put an alert form, So I used quaggaJS there.

@JuliaRakitina

This comment has been minimized.

Copy link

@JuliaRakitina JuliaRakitina commented Sep 25, 2018

I tried this solution for DATA_MATRIX

                ArrayList<BarcodeFormat> formatList = new ArrayList<BarcodeFormat>();
                formatList.add(BarcodeFormat.QR_CODE);
                formatList.add(BarcodeFormat.DATA_MATRIX);

But it does not work. Seems like cordova does not recompile plugins, because if I delete QR_CODE at all, it still work and decodes it

@JuliaRakitina

This comment has been minimized.

Copy link

@JuliaRakitina JuliaRakitina commented Sep 25, 2018

Solved by remove/add platform

@sonicwong

This comment has been minimized.

Copy link

@sonicwong sonicwong commented Apr 10, 2019

iOS Code for plugin v3.0.1

metaOutput!.metadataObjectTypes = [AVMetadataObject.ObjectType.qr, AVMetadataObject.ObjectType.ean13, AVMetadataObject.ObjectType.code128, AVMetadataObject.ObjectType.code39]

if ((found.type == AVMetadataObject.ObjectType.qr || found.type == AVMetadataObject.ObjectType.ean13 || found.type == AVMetadataObject.ObjectType.code128 || found.type == AVMetadataObject.ObjectType.code39) && found.stringValue != nil) {

@sunhongjian

This comment has been minimized.

Copy link

@sunhongjian sunhongjian commented Oct 25, 2019

@sonicwong thanks,This problem has been solved by your response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can鈥檛 perform that action at this time.