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,

  2. set supportedNativeBarcodeFormats in ScanView to the list of barcode formats you would like to detect (Important: do this before starting the scan view camera)

  3. implement the method -[scanView:didReceiveBarcodeResult:] in the delegate

Setting up the view controller to listen for native barcodes
@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

For a list of supported formats, refer to AVMetadataObject.h.

Take note that simply because a constant exists for a barcode format in that list doesn’t imply that the device necessarily supports it. Commonly-supported types include: CODE_128, CODE_39, QR_CODE, AZTEC, DATA_MATRIX, PDF_417, UPC_E, CODABAR, EAN_13, EAN_8, and MICRO_QR.

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.