Integrate the Scandit Barcode Scanner into your app

This guide shows how to use the unified API for scanning barcodes in your application.

Get the Scandit Barcode Scanner

The unified barcode scanner API is available as a NuGet package and can easily be installed via For details on how to add a NuGet package to your project, take a look at the guides for Xamarin Studio, or Visual Studio. Search for the Scandit.BarcodePicker.Unified package and add it to your project. You will need to add a reference to the portable class library where your barcode scanning logic is going to be implemented, and to the iOS/Android and Windows applications. The latter is required to also include the platform-specific portion of the code into your app.

Windows: Modify the App Manifest

These instructions only apply if you are also targeting Windows. You will have to make a few changes to the app manifest:

  • Update the App manifest to include microphone and webcam capabilities. Without it you will get a null-pointer exception when trying to initialize scanner.
  • Update the app manifest XML to contain the following extension. This class is required for accessing the raw camera frames from the VideoInputRT dll.
<Extension Category="windows.activatableClass.inProcessServer">
<ActivatableClass ActivatableClassId="VideoInputRT.FrameAccess" ThreadingModel="both" />

Windows: Using the scanner from a Subpage

If you are on Windows and want to launch the scanner from a sub page, e.g. not the application's root page, you will have to make a change to MainPage.xaml to change the navigation cache behavior. Add the NavigationCacheMode="Required" to the MainPage. The reason for this is that the page content and state are not cached by default on UWP and after pushing another native page onto the navigation stack and going back to the previous page, the state of MainPage is reset, which effectively reloads the Xamarin.Forms app.

Add the barcode scanner namespace to easily access its classes

If you don't want to type the whole namespace each time when using the scanner you should add a using directive at the top of the class you will use the scanner in:

Set the app key

Sign in to your account at to look up your app key in the Download section.

App Key in your account

The application key must be set before you use the barcode picker for the first time. Typically you will put this code into the Page constructor that uses the barcode picker:

// Must be set before you use the picker for the first time.
ScanditService.ScanditLicense.AppKey = "-- ENTER YOUR SCANDIT LICENSE KEY HERE --";

Add code to start the scanning process

In the unified API, the barcode picker is a singleton whose instance will be different depending on the platform the code runs on. To scan a barcode, these 3 steps are neccessary. 1. configure the barcode picker, 2. register a DidScan delegate, 3. start the scanning. These steps are shown in the code sample below:

// Configure the barcode picker through a scan settings instance by defining which
// symbologies should be enabled.
var settings = ScanditService.BarcodePicker.GetDefaultScanSettings();
// prefer backward facing camera over front-facing cameras.
settings.CameraPositionPreference = CameraPosition.Back;
// Enable symbologies that you want to scan.
settings.EnableSymbology(Symbology.EAN13, true);
settings.EnableSymbology(Symbology.UPCA, true);
settings.EnableSymbology(Symbology.QR, true);
ScanditService.BarcodePicker.DidScan += OnDidScan;
await ScanditService.BarcodePicker.ApplySettingsAsync(settings);
// Start the scanning process.
await ScanditService.BarcodePicker.StartScanningAsync();

Note: You can force the barcode picker to be always shown modally. Please be aware that, this functionality only exists for iOS at the moment.

You can use this feature like this:

ScanditService.BarcodePicker.AlwaysShowModally = true;

Add code to handle the scanning event

To be notified when a barcode is scanned, add a delegate to the DidScan event of the barcode picker. A possible implementation of such a delegate looks like this:

void OnDidScan(ScanSession session)
// Guaranteed to always have at least one element, so we don't have to
// check the size of the NewlyRecognizedCodes array.
var firstCode = session.NewlyRecognizedCodes.First();
var message = string.Format("Code Scanned:\n {0}\n({1})", firstCode.Data,
// Because this event handler is called from an scanner-internal thread,
// you must make sure to dispatch to the main thread for any UI work.
Device.BeginInvokeOnMainThread(() => {
this.ResultLabel.Text = message;
ScanditService.BarcodePicker.DidScan -= OnDidScan;

Careful: The delegate is invoked on a picker-internal queue. To perform any UI work, you must dispatch to the main UI thread.

Next steps

  • Experiment with the extended demo app that allows to set all Scandit Barcode Scanner API options