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 NuGet.org. 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.
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 http://account.scandit.com to look up your app key in the Download section.

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:
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:
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:
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:
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