Quick Start

Follow this guide to set up a project for Xamarin.iOS in order to easily implement the Anyline SDK.

The Xamarin Bundle

The Xamarin SDK Bundle that you can download from GitHub contains the following parts for you to get started in Xamarin:

  • BindingSource - Xamarin iOS and Android Binding Libraries

  • Examples - Xamarin.iOS, Xamarin.Android, and Xamarin.Forms example apps

  • com.anyline.xamarin.examples_<version>.apk - Prebuilt Android APK ready to install on your Android device

Requirements

To use the Anyline SDK for Xamarin.iOS you need:

  • An iOS device with minimum version 12

  • An iPhone 5s or newer

  • An Apple developer account, and your device set up for development

Apple Developer Account

In order to set up an Apple Developer Account and the device, please follow the Device Provisioning Guide from the Xamarin Documentation.

Developing on a Windows Machine

If you want to develop on a Windows machine, you will require a Mac Build Host.
For more information, please check out the Windows Installation Guide from the Xamarin Documentation on how to install and run Xamarin.iOS projects on Windows.

Setup

In this section we will go through the basic process of creating and configuring a simple Anyline scanning application in Xamarin.iOS. If you are not yet familiar with Xamarin.iOS, follow the Official Xamarin iOS Getting Started Guide to develop an understanding on the fundamentals of iOS application development with Xamarin.

Create a new Xamarin.iOS Project

If you are using Visual Studio, click File > New Project…​, select Visual C# > iOS > iPhone and create a new Single View App for iPhone.

Build Host

If using Windows, make sure your macOS build host is up and running, and pair Visual Studio with the build host. If you have any troubles with this step, please refer to the Troubleshooting Guide on the Xamarin Documentation.

Add the Anyline SDK via NuGet

To access the functionality of our SDK, simply right-click on your project, go to manage Nuget packages.. and search for "Anyline".

Select Anyline.Xamarin.SDK.iOS, install the latest available version, and accept the license agreement.

Generate an Anyline License Key

In order to run the Anyline SDK in your app, you require a license key.

In order to create a license key for your application, you have to identify the bundle identifier of your Xamarin.iOS app.

License <> Bundle Identifier

Every license is bound to an bundle identifier. If you change your bundle identifier, you will require a new license. This also ensures that your license key cannot be used in any other application.

How to identify the Bundle Identifier

To generate a license key for your application, refer to the bundle identifier of your Xamarin.iOS project. It is located under Properties > iOS Application > Identifier.

Initialize the SDK

Initialize the Anyline SDK in your ViewController, or in another place your preference.

The Anyline SDK only needs to be initialized before its first usage, and only one time within the app’s lifecycle.

public override void ViewDidLoad()
{
    base.ViewDidLoad();

    ...

    // INSERT YOUR LICENSE KEY HERE
    string licenseKey = "YOUR_LICENSE_KEY";

    // INITIALIZE THE ANYLINE SDK
    bool validLicense = AnylineXamarinSDK.iOS.AnylineSDK.SetupWithLicenseKey(licenseKey, out NSError licenseError);

    if (!validLicense)
    {
        var okAlertController = UIAlertController.Create("License Exception", licenseError.LocalizedDescription, UIAlertControllerStyle.Alert);
        okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
        PresentViewController(okAlertController, true, null);
        System.Diagnostics.Debug.WriteLine(licenseError.LocalizedDescription);
    }

}

In the next section, we will implement a ScanView and provide a configuration to customize visual parameters and behaviours.