On this page

Stuck? Open a support ticket and the barKoder team will help. Open a ticket

Installation

Following is the guide for utilizing the the barKoder Xamarin Plugin. Follow the simple steps below to use the barKoder SDK in your Xamarin project:

1. Add the package #

Add our Barkoder.Xamarin nuget package from source "nuget.org" #

Import package #

C#
using Barkoder.Xamarin;

2. Allow the camera #

Camera permission #

Our SDK requires camera permission to be granted in order to use scanning features. For Android, the permission is set in the manifest from the package. For iOS you need to specify camera permission in Info.plist file inside your project

XML
<key>NSCameraUsageDescription</key>
<string>Camera permission</string>

3. Add the scanner view #

Add BarkoderView #

C#
private BarkoderView BkdView;

Android #

C#
BkdView = FindViewById<BarkoderView>(Resource.Id.barkoderView);

iOS #

C#
BkdView = new BarkoderView();
var barkoderView = BkdView.View;

BkdView = new BarkoderView();
var BarkoderView = BkdView.View;
View.AddSubview(BarkoderView);

...

// TODO: Add constraints to BarkoderView

Both #

C#
// In order to perform scanning, config property need to be set before

BkdView.Config = new BarkoderConfig("LICENSE_KEY");
BkdView.Config.DecoderConfig = new DecoderConfig();

4. Set the license key and barcode types #

Optional barkoder settings #

General barcode settings #

C#
private void SetBarkoderSettings()
{
    // These are optional settings, otherwise default values will be used
    BkdView.Config.ImageResultEnabled = true;
    BkdView.Config.LocationInImageResultEnabled = true;
    BkdView.Config.RegionOfInterestVisible = true;
}

Barcode types iOS #

C#
private void SetActiveBarcodeTypes()
{
    /// There is option to set multiple active barcodes at once as array
    BkdView.Config.DecoderConfig.SetEnabledDecoders(
        new NSNumber[] {
            (int)DecoderType.Qr,
            (int)DecoderType.Ean13
        }
    );

    // or configure them one by one
    BkdView.Config.DecoderConfig.UpcA.Enabled = true;
}

Barcode types Android #

C#
private void SetActiveBarcodeTypes()
{
    /// There is option to set multiple active barcodes at once as array
    BkdView.Config.DecoderConfig.SetEnabledDecoders(
        new BKD.DecoderType[] {
            BKD.DecoderType.Qr,
            BKD.DecoderType.Ean13
        }
    );

    // or configure them one by one
    BkdView.Config.DecoderConfig.UpcA.Enabled = true;
}

Licensing #

The SDK will scan barcodes even without a license, but results will come with an "(Unlicensed)" prefix.  By using our software, you are agreeing to our End User License Agreement. To obtain a valid license, one should create an account here and either get a trial license (to test the software out) or procure a production license that can be used within a production build.

5. Start scanning and read results #

Ready to Scan Event #

Inside MethodResultCallBackDecoderResultWithCompletion callback function the SDK is fully initialized and ready for configuration or to start the scanning process

Start scanning iOS #

C#
// Starting to scan
BkdView.StartScanning((result) =>
    // Fetching data
    // TODO: Getting results
);

Start scanning Android #

C#
// Starting to scan
BkdView.StartScanning(this);

// Fetching data
public void ScanningFinished(BKD.Result[] results, Bitmap resultImage)
{
    // TODO: Getting results
}