iOS Update Guide for Anyline 6

Anyline 6

The Anyline SDK introduced new structure concept. The SDK is now composed from ScanView, ScanViewPlugins and ScanPlugins, being more structured and easy to implement. The components (ScanView, ScanViewPlugin and ScanPluign) are described in: iOS Plugins.

This document will guide you through the necessary steps to upgrade your app to work with the Anyline SDK 6.

Old Module Implementation vs. New Plugin Implementation

In the older versions of Anyline, the ScanModuleView was handling every part of the Anyline SDK. The View Elements are now separated from the use case code.

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

  • A ScanPlugin
    • The ScanPlugin handles the image processing and the scanning functionality itself.
    • Everything reg√ľarding 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.

The Delegates and the start/stop methods were also updated with Anyline 6. For more informatino please checkout iOS Plugins for a general plugin implementation or iOS Plugin Specifics for plugin specific implementations.

The following code snippets show how the instantiating of the Anyline SDK differs from Anyline 3.x.x to Anyline 6:

Old Module Implementation
self.anylineEnergyView = [[AnylineEnergyModuleView alloc] initWithFrame:frame];

NSError *error = nil;
// We tell the module to bootstrap itself with the license key and delegate. The delegate will later get called
// once we start receiving results.
BOOL success = [self.anylineEnergyView setupWithLicenseKey:kAutoAnalogDigitalMeterScanLicenseKey delegate:self error:&error];

// setupWithLicenseKey:delegate:error returns true if everything went fine. In the case something wrong
// we have to check the error object for the error message.
if( !success ) {
    // Something went wrong. The error object contains the error description
    [[[UIAlertView alloc] initWithTitle:@"Setup Error"
                      otherButtonTitles:nil] show];

// After setup is complete we add the module to the view of this view controller
[self.view addSubview:self.anylineEnergyView];
New Plugin Implementation
//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);

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

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

//Add Anyline to view hierachy
[self.view addSubview:self.scanView];
//Start Camera
[self.scanView startCamera];

New JSON Configuration

For Anyline 4, there is a new JSON file structure. The JSON file must contain now the viewPlugin field. Optionally it may contain the plugin field which is initialising internally the specific Scan Plugin. The list of parameters are described in: View Configuration as well as the call for JSON file can be found at: iOS View Configuration