Installation guide for barKoder's Maui Barcode Scanner SDK plugin

This is a guide for the Maui plugin powered by the barKoder Barcode Scanner SDK.

1. Add our Plugin.Maui.Barkoder nuget package. #

2. 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 Platforms/iOS/Info.plist file inside your project

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

3. Adding Maui Handlers #

To integrate Barkoder functionality into your Maui application, you'll need to configure the BarkoderHandler inside your main MauiProgram.cs file.

                using Plugin.Maui.Barkoder.Controls;
            

Next, within your MauiProgram.cs file, you'll configure the Maui handlers by adding the BarkoderViewHandler.

                var builder = MauiApp.CreateBuilder();
builder
        .UseMauiApp<App>()
        .ConfigureFonts(fonts =>
        {
            // Your custom fonts
        })
        .ConfigureMauiHandlers(handlers =>
        {
            // Your other maui handlers
            handlers.AddHandler(typeof(BarkoderView), typeof(BarkoderViewHandler));
    });
            

4. Adding BarkoderView #

4.1. Add Namespace Declaration

In your XAML file where you want to use the plugin, add a namespace declaration for the plugin assembly. This allows you to reference the controls provided by the plugin in your XAML markup. For example:

                xmlns:barkoder="clr-namespace:Plugin.Maui.Barkoder.Controls;assembly=Plugin.Maui.Barkoder"
            

In your XAML.cs file, add the following lines to access Barkoder's classes, enumerations, and interfaces

                using Plugin.Maui.Barkoder.Handlers;
using Plugin.Maui.Barkoder.Interfaces;
using Barkoder;
            

4.2. Add the View

Once you've added the namespace declaration, you can now use the controls provided by the plugin in your XAML markup. For example, to add a BarkoderView control, you can use the following markup:

                <barkoder:BarkoderView
    x:Name="BKDView"
    barkoder:LicenseKey="YOUR_LICENSE_KEY"
    HeightRequest="200"/>
            

Replace "YOUR_LICENSE_KEY" with your actual license key provided by the plugin.

4.3. Adding configuration

In your code-behind (XAML.cs) file you can configure optional settings for the BarkoderView control. Here's how you can implement it:

                using Plugin.Maui.Barkoder.Enums;

...

private void SetBarkoderSettings()
{
  // These are optional settings, otherwise default values will be used
  BKDView.SetImageResultEnabled(true);
  BKDView.SetLocationInImageResultEnabled(true);
  BKDView.SetRegionOfInterestVisible(true);

  // Enable desired barcode type
  BKDView.SetBarcodeTypeEnabled(BarcodeType.QR, true);
  BKDView.SetBarcodeTypeEnabled(BarcodeType.Code128, true);
}
            

5. Ready to Scan Event #

To begin scanning, ensure that you have implemented the IBarkoderDelegate interface and then call the StartScanning method from BKDView

                public class YourPage : ContentPage, IBarkoderDelegate
{
    // Your existing methods and properties...

    // Method to start the scanning process
    private void StartScanning()
    {
        // Start scanning using the BarkoderView control and pass 'this' as the delegate
        BKDView.StartScanning(this);
    }

    // Implementing the DidFinishScanning method from IBarkoderDelegate
    public void DidFinishScanning(BarcodeResult[] result)
    {
        // Handle the scanned result here
        foreach (var barcode in result)
        {
            // Do something with each barcode result, for example:
            Console.WriteLine($"Scanned barcode: {barcode.TextualData}");
        }
    }
}
            

6. Licensing #

The SDK will scan barcodes even without a valid license; however all results will be randomly masked with (*) Asterisk characters. 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 live app.

Page Contents

History:

close