Barcode

Full Screen Scanning

To simulate fullscreen scanning for your plugins, simply omit the cutoutConfig node in the config JSON.

{
    "viewPluginConfig": {
        "pluginConfig": {
            "id": "barcode_fullframe",
            "barcodeConfig": {
                "barcodeFormats": [ "ALL" ]
            },
            "cancelOnResult": true
        },
        "scanFeedbackConfig": {
            "style": "rect",
            "strokeWidth": 1,
            "strokeColor": "#0099FF",
            "fillColor": "#330099FF",
            "beepOnResult": false,
            "vibrateOnResult": false,
            "blinkAnimationOnResult": false
        }
    }
}

This will allow objects being scanned to be detected wherever they are visible in the scan view. No cutout will be displayed.

In code, use the ALCutoutConfig’s defaultCutoutConfig method or pass a null value to the ALScanViewPluginConfig initializer.

While full frame scanning could technically be used on any Anyline plugin, this is only tested to work well with barcodes. Alternatively, you can simulate the clean look without the cutout by setting the strokeWidth and outerAlpha to 0 and adjusting the cutout region to fill as much of the scan view frame as possible.

Native Barcode Scanning

You can also make use of iOS' own barcode scanning functionality to run alongside an Anyline scan plugin. Any supported barcodes found will be returned through a delegate call sent from the ScanView.

To use native barcode detection in Anyline 43, take the following steps:

  1. set a delegate to your ScanView, and implement the method -[scanView:didReceiveBarcodeResult:] in the delegate

  2. assign to ALScanView.supportedNativeBarcodeFormats a non-null array of barcode formats (Important: do this before starting the scan view camera).

If the list supplied to supportedNativeBarcodeFormats is empty, this is taken to mean ALL supported barcode types.

  • Swift

  • Objective-C

override func viewDidLoad() {
    super.viewDidLoad()

    // ...
    scanView.delegate = self
    scanView.supportedNativeBarcodeFormats = [.qr, .pdf417 ]
    scanView.startCamera()

}

func scanView(_ scanView: ALScanView, didReceiveNativeBarcodeResult scanResult: ALScanResult) {
    // use the barcode results: `-[event JSONObject]` contains
    // details about the barcode detected
}
@interface MyViewController () <ALScanViewDelegate>
@end

@implementation MyViewController

- (void)viewDidLoad {

    // ...
    scanView.delegate = self;
    scanView.supportedNativeBarcodeFormats = @[ AVMetadataObjectTypeQRCode, AVMetadataObjectTypePDF417Code ];
    [scanView startCamera];
}

- (void)scanView:(ALScanView *)scanView didReceiveNativeBarcodeResult:(ALScanResult *)event {
    // use the barcode results: `-[event JSONObject]` contains
    // details about the barcode detected
}

@end

Use constants defined in AVMetadataObject.h for the list. Commonly-supported formats include the following: AVMetadataObjectTypeCode128Code, AVMetadataObjectTypeQRCode, AVMetadataObjectTypeAztecCode, AVMetadataObjectTypeDataMatrixCode, AVMetadataObjectTypePDF417Code, AVMetadataObjectTypeEAN13Code, and AVMetadataObjectTypeEAN8Code.

Take note that simply because a constant exists for a barcode format in that list doesn’t imply that the device necessarily can support it.

Limitations

At the moment, native barcode scanning has a number of limitations:

  • The delegate method -[scanView:didReceiveBarcodeResult:] is called continuously for as long as a supported barcode is in the frame. Apart from this, there is also no default feedback given to inform the user know that a barcode has been detected in this way.

  • Depending on the operating system version of the device running it, as well as other factors, some barcode formats in AVMetadataObject.h may not be fully supported.

  • Besides selecting the formats the iOS barcode library should detect, configuration options are limited.

  • The results are provided on a "best-effort" basis. Anyline does not guarantee the correctness or accuracy of the results returned from native barcode detection.

If the limitations make it hard to implement your use case, consider using the Anyline Barcode plugin, and potentially in a parallel composite setup together with another plugin.