To make it easier for developers to implement the Anyline SDK, it is based on Plugins. You can use these Plugins to implement your scanning use case into your application.

This section describes how to implement and use the Anyline SDK plugins in iOS.

General Plugin Implementation


All the examples provided here are based on the Meter Plugin. Specific implementations can be found in the next section, and in the iOS API Reference.

How to implement an Anyline Plugin

Starting with Anyline 4 each use case needs three components to successfully scan:

  • A ScanPlugin
    • The ScanPlugin handles the image processing and the scanning functionality itself.
    • Everything regarding scanning will be handled by the ScanPlugin.
  • A ScanViewPlugin
    • The ScanViewPlugin handles the UI and the VisualFeedback, which will be presented to the user.
    • Everything regarding UI configuration will be handled by the ScanViewPlugin.
    • A ScanViewPlugin has to be instantiated with a ScanPlugin and optionally with a UI Config.
  • A ScanView
    • The ScanView will handle the camera, the flash and manage the previously created ScanViewPlugin and ScanPlugin.
    • The ScanView will be instantiated with a frame and the ScanViewPlugin. The frame will define the size of the ScanPlugin, the ScanViewPlugin and the ScanView.

Add the Anyline Plugins to your UIViewController

The first step is to add these three main components of Anyline to your UIViewController: the Scan Plugin (handling the scanning part), the Scan View Plugin (handling the UI) and the Scan View (handling camera, flash and overall communication between Anyline components).

Add the Anyline Meter Plugins
// The Anyline plugins used to scan
@property (nonatomic, strong) ALMeterScanViewPlugin *meterScanViewPlugin;
@property (nonatomic, strong) ALMeterScanPlugin *meterScanPlugin;
@property (nullable, nonatomic, strong) ALScanView *scanView;

Anyline ScanPlugin

Initialise the Scan Plugin

You have to initialise the plugin with your Anyline License Key Generation, an ID (String) and the delegate inside viewDidLoad.

License Key

It’s easiest to add your License Key as a NSString * const to your ScanViewController

Initialise the Scan Plugin
    //Add Meter Scan Plugin (Scan Process)
    NSError *error = nil;
    self.meterScanPlugin = [[ALMeterScanPlugin alloc] initWithPluginID:@"ENERGY" licenseKey:kDemoAppLicenseKey delegate:self error:&error];
    NSAssert(self.meterScanPlugin, @"Setup Error: %@", error.debugDescription);

Anyline ScanViewPlugin

Initialise the Scan View Plugin

After initialising the scanPlugin, the next step is to create the scanViewPlugin with the scanPlugin you just created. The ScanViewPlugin will handle and display the UI used for scanning.

Initialise the Scan View Plugin
    //Add Meter Scan View Plugin (Scan UI)
    self.meterScanViewPlugin = [[ALMeterScanViewPlugin alloc] initWithScanPlugin:self.meterScanPlugin];

Set the ScanViewPluginConfig

The View Configuration configurates the look and feel of the scanning process. You can set it the following way:

Set the ScanViewPluginConfig
NSString *confPath = [[NSBundle mainBundle] pathForResource:@"meter_capture_config" ofType:@"json"];
ALScanViewPluginConfig *scanViewPluginConfig = [ALScanViewPluginConfig configurationFromJsonFilePath:confPath];

self.meterScanViewPlugin = [[ALMeterScanViewPlugin alloc] initWithScanPlugin:self.meterScanPlugin

Limitations for the Meter Plugin

The Size and Ratio are fixed and optimised for the best results
The Cutout Alignment should be set to TOP with a little offset, as this reduces reflections

Anyline ScanView

Initialise the Scan View

The last Anyline Object you have to create is the so called scanView, it will handle the camera, the flash and manage the previously created ScanViewPlugin and ScanPlugin. You need to instantiate the scanView with the previous created scanViewPlugin and the frame it should occupy. Usually, that’s the bounds of the screen.

Initialise the Scan View
    //Add ScanView (Camera and Flashbutton)
    self.scanView = [[ALScanView alloc] initWithFrame:frame scanViewPlugin:self.meterScanViewPlugin];

Adding the Scan View to the View Hierarchy and start the Camera Feed

To add the scanView to your view hierarchy add the following in viewDidLoad:

Adding the view and starting the camera
    [self.view addSubview:self.scanView];
    [self.scanView startCamera];

Starting the Scan Process


Use [scanView startCamera] within viewDidload before starting Anyline.

After everything is initialised, you can start the scanning process, by calling startAndReturnError: on the plugin.

It is advised to place this call in the viewDidAppear: lifecycle method of the UIViewController.

Starting the plugin
 This method will be called once the view controller and its subviews have appeared on screen
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
     This is the place where we tell Anyline to start receiving and displaying images from the camera.
     Success/error tells us if everything went fine.
    NSError *error = nil;
    BOOL success = [self.meterScanViewPlugin startAndReturnError:&error];
    if( !success ) {
        // Something went wrong. The error object contains the error description
        [[[UIAlertView alloc] initWithTitle:@"Start Scanning Error"
                          otherButtonTitles:nil] show];

Stop Scanning

To stop the scanning process, call stopAndReturnError: on the plugin.

To make sure the SDK is properly stopped upon leaving the Activity, make sure to place stopAndReturnError: in the viewWillDisappear: lifecycle method of the UIViewController.

Stopping the plugin
 Cancel scanning to allow the module to clean up
- (void)viewWillDisappear:(BOOL)animated {
    [self.meterScanViewPlugin stopAndReturnError:nil];

Check license Expiry Date

New in version 3.24.

The ALCoreController provides a static method to check the expiry date from a license key string. A NSString containing the date will be returned. If the license cannot be parsed, an error will be returned.

Check License Expiry Date
NSError *error = nil;
NSString *dateString = [ALCoreController licenseExpirationDateForLicense:YOUR_LICENSE_KEY_STRING error:&error];
// Handle Error after.

Plugin Specifics

Currently there are six plugins

Anyline OCR Plugin

With the AnylineOCR Plugin, you have the ability to create your own OCR use case, on the fly with almost no effort. It offers a variety of parameters for you to adjust the scanning process to your use case.

Anyline OCR Plugin    
Anyline OCR Documentation of the Plugin iOS Plugin Implementation Details

Meter Plugin

The Anyline Energy plugin is capable of scanning Analog Electric-, Gas- and Water Meter readings. It is also possible to scan Bar- and QR-codes, which is useful for identifying meters, as well as the Serial Number. Common Digital Meters and Heat Meters can also be scanned.

Meter Plugin    
Anyline meter Documentation of the Plugin iOS Plugin Implementation Details

ID Plugin

The Anyline ID plugin provides the functionality to scan passports and other IDs holding a Machine Readable Zone (MRZ). Additionally this plugin is also capable to scan Driving Licenses.

ID Plugin    
Anyline ID Documentation of the Plugin iOS Plugin Implementation Details

Barcode Plugin

With the Anyline Barcode-Plugin 23 different formats of Bar- and QR-Codes can be scanned.

Barcode Plugin    
Anyline Barcode Documentation of the Plugin iOS Plugin Implementation Details

Document Plugin

The Anyline Document Plugin detects document outlines, validates the angles of the document to ensure the it is not too skewed, determines the sharpness of the text and rectifies the document.

Document Plugin    
Anyline Document Documentation of the Plugin iOS Plugin Implementation Details

License Plate Plugin

With the Anyline License Plate Plugin provides functionality to scan a variety of license plates from different countries.

License Plate Plugin    
License Plate Documentation of the Plugin iOS Plugin Implementation Details