Xamarin Barcode Scanner SDK - Getting Started
Download & Installation
The Scanbot Barcode Scanner SDK for Xamarin is provided as 2 NuGet packages:
- ScanbotBarcodeSDK.Xamarin - contains the Scanbot Barcode Scanner SDK Xamarin Native bindings and wrappers for Android and iOS
- ScanbotBarcodeSDK.Xamarin.Forms - provides portable Scanbot Barcode Scanner SDK wrappers for use with Xamarin.Forms
Install ScanbotBarcodeSDK.Xamarin.Forms
if your project is based on Xamarin.Forms,
otherwise install ScanbotBarcodeSDK.Xamarin
.
You can install them directly via Visual Studio IDE: Open your App-Solution in Visual Studio, select your iOS or Android project and click on the menu item Project -> Add NuGet Packages. Make sure nuget.org is selected as the source and search for the package.
By clicking on Add Package the Scanbot Barcode Scanner SDK will be downloaded and installed into your project.
Do that for both your iOS and Android projects.
Also, ScanbotBarcodeSDK.Xamarin.Forms
must be installed in the portable app project
(if one exists - not necessary if you are using a shared project).
Register dependencies (Forms)
If you are using ScanbotBarcodeSDK.Xamarin.Forms you will need to manually register the dependencies like shown:
MainActivity.cs
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
ScanbotBarcodeSDK.Forms.Droid.DependencyManager.Register(this);
//...
}
AppDelegate.cs
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
ScanbotBarcodeSDK.Forms.iOS.DependencyManager.Register();
//...
}
Permissions
Required permissions for Android
Make sure to add the Camera permission in your AndroidManifest.xml
file:
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
Required permissions for iOS
Add the following properties to your Info.plist
file:
- "Privacy - Camera Usage Description" (
NSCameraUsageDescription
). Describe why your app wants to access the device's camera.
Android Settings
Optional: ABI Settings
The Scanbot Barcode Scanner SDK uses native libraries under the hood and supports the following
ABIs:
armeabi-v7a
, arm64-v8a
, x86
and x86_64
.
Please adjust the Supported ABIs configuration in your Android project settings accordingly:
Android Project => Properties => Android - Other => Supported ABIs ...
Please note:
In most cases the architectures x86
and x86_64
can be removed for the release (production) build,
since they are only used on emulators and on some rare devices with the Intel Atom architecture.
Furthermore, please increase the Java Heap Size value to 4G. This is required for the build process.
Optional: ProGuard
If you need to enable ProGuard for your Android release build, please check this full list of the ProGuard rules for the Scanbot SDK.
iOS settings
Set Linker Behaviour
to
Link SDK assemblies only
Want to scan longer than one minute?
Generate a free trial license to test the Scanbot SDK thoroughly.
Get your free Trial LicenseWhat do you think of this documentation?
What can we do to improve it? Please be as detailed as you like.