I'm attempting to update a cordova app to read CODABAR format barcodes.
The barcode scanning plugin in use on iOS relies on the AV Foundation framework to set up an AVCaptureSession to activate the camera and intercept image frames.
Most of the cordova plugins & iOS tutorials around the web use this method, and attach a AVCaptureMetadataOutput instance to specify which barcode formats we're interested in.
eg.
outputItems = [[AVCaptureMetadataOutput alloc] init];
[outputItems setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
[captureSession addOutput:outputItems];
outputItems.metadataObjectTypes = [outputItems availableMetadataObjectTypes];
Unfortunately, CODABAR is not one of the supported formats.
Once the plugin is sent the frames, it's using ZXing to process the image. ZXing supports all the formats I want, but since AVCaptureMetadataOutput doesn't allow you to specify CODABAR, my plugin never receives the images.
Is there an alternative to using an AVCaptureSession to process frames on the camera? Am I missing a way to force the frames to be sent through despite the "unblessed" barcode format?
Ah. Found it I think.
The codebase still has references to the zxing calls, but swapped out using it without removing the old code, which led me down the wrong path.
Before it changed, it was using AVCaptureVideoDataOutput to process the frames itself.
Then it changed to using AVCaptureMetadataOutput instead, delegating the image processing to AV Foundation instead of zxing.
Looks like to add codabar support, I may need to reverse this, since AV Foundation doesn't do codabar.
UPDATE: About a year old now, but to tidy off this old question, I went ahead with the solution I suggested above since there didn't appear to be anything other way for this on iOS. Here's part of my comment on the plugin's github issue:
It turns out that:
Old versions of this plugin, in iOS, used an (ancient) snapshot of the ZXing c++ port. That library didn't support Codabar at the time.
At some point, the iOS version switched to using the iOS AV Foundation framework instead, delegating the barcode decoding to AVCaptureMetadataOutput. This framework doesn't support codabar either. This switch was necessary due to memory leaks found in the old c++ zxing approach, discovered when iOS 10 landed on everyone.
I've attempted to integrate this plugin with a more recent Objective C port of ZXing. This does support codabar, along with a few extra formats currently missing from the iOS version of this plugin.
My attempt is over here: https://github.com/otherchirps/phonegap-plugin-barcodescanner
My iOS project is now scanning codabar barcodes using this version of the plugin.
This was based on the earlier efforts to do the same found here: https://github.com/dually8/BarcodeScanner