Please note that Microblink is no longer maintaining this repository.
As such, there will be no additional updates or releases for this codebase. You are welcome to continue using the code, as it remains source available.
Furthermore, if you need to update it for a newer SDK or platform version, you can do so by forking this repository and maintaining the fork independently.
If you have questions regarding such, please contact our support team at [email protected].
Enhance your Xamarin cross-platform apps with an AI-driven mobile ID scanning software.
Please note that, for maximum performance and full access to all features, it’s best to go with one of our native SDKs (for iOS or Android).
Below you can try out our sample app, read the integration guides for both Android and iOS and study advanced topics ⬇️
Steps for integrating BlinkID into your Xamarin Forms project:
- In both your
Core,DroidandiOSprojects, addBlinkID.FormsNuGet package as a reference. - In your
Droidproject, update yourMainActivity.csin a following way:- update your
MainActivityclass so that it implementsBlinkID.Forms.Droid.IMicroblinkScannerAndroidHostActivity. This interface specifies 2 properties and 1 method that you must implement:HostActivityproperty must return reference to current host activity.ScanActivityRequestCodeproperty must return integer that will be used as request code for Android'sStartActivityForResultinvocationScanningStartedmethod will be called just before scanning starts. It will receive currently usedMicroblinkScannerImplementationas a parameter. You should save a reference to this object because you will need it later in your implementation ofOnActivityResult
- override
Activity'smethodOnActivityResultand pass its parameters to reference ofMicroblinkScannerImplementation
- update your
- Your
iOSproject does not need any modifications. - In your
Coreproject, obtain a reference toIMicroblinkScannerFactoryusing aDependencyService - Use a factory to create an instance of
IMicroblinkScanner. - Use the dependency service to create recognizer you wish to use
- Subscribe to
Messages.ScanningDoneMessagethat will inform you whether the scanning has completed or was cancelled by end user - Using on or more of recognizer objects obtained in step 6., create an instance
IRecognizerCollectionusingIRecognizerCollectionFactoryobtained viaDependencyService - Create a settings object for desired UI overlay
- Start scanning by invoking method
Scanon instance ofIMicroblinkScanner
Xamarin Forms sample app is available here.
In your native Android project, add reference to BlinkID.Android.Binding NuGet package and follow the integration instructions for BlinkID Android SDK.
Native Android sample app is available here.
In your native iOS project, add reference to BlinkID.iOS.Binding NuGet package and follow the integration instructions for BlinkID iOS SDK.
Native iOS sample app is available here.
If you do not wish to use BlinkID NuGet packages, you can directly reference binding projects in your solutions. Just make sure that following conditions are met:
- all large binary files have been checked out
- to ensure that all files have been checked out, please make sure that you have installed Git Large File Storage and that you have fetched all LFS files with
git lfs pullcommand.
- to ensure that all files have been checked out, please make sure that you have installed Git Large File Storage and that you have fetched all LFS files with
- your solution has referenced all dependencies of the project that you are referencing
Binding- Xamarin iOS and Android Binding Libraries and Xamarin Forms project from which all mentioned NuGet packages were builtSamples- Xamarin.iOS, Xamarin.Android and Xamarin.Forms sample applications
- Download latest AAR from Android SDK repository
- Replace
Binding/Android/Jars/LibBlindID.aarwith latest AAR - Open
Binding/Forms/BlinkID.Forms/BlinkID.Forms.slnsolution - If needed, update
Transforms/Metadata.xmlinAndroidBindingproject. - Right-click the
AndroidBindingproject, selectOptions, underNuGet Packagesection selectMetadata - Update
Versionon tabGeneral - Update
Release noteson tabDetails - Rebuild the
AndroidBindingproject
-
Download latest MicroBlink.bundle and MicroBlink.framework from iOS SDK repository
-
Replace
Binding/iOS/MicroBlink.bundleandBinding/iOS/MicroBlink.frameworkwith latest versions -
Generate new
ApiDefinitions.csandStructsAndEnums.cswith latest version of Objective Sharpie, but DO NOT OVERWRITE existingApiDefiniton.csandStructs.cs- you can generate new
ApiDefinitions.csandStructsAndEnums.cswith following command (replaceiphoneos11.4with latest SDK you have on your Mac):
cd Binding/iOS sharpie bind -sdk iphoneos11.4 MicroBlink.framework/Headers/MicroBlink.h -scope MicroBlink.framework/Headers -namespace Microblink -c -F . - you can generate new
-
Manually merge new structures from generated
StructsAndEnums.csinto existingStructs.cswhile fixing compile errorssharpiegenerates enums with underlying types such asnuintornintwhich are not supported by latest version of C# - you must replace those withuintorinttypes.
-
Manually merge new API classes from generated
ApiDefinitions.csinto existingApiDefinition.cs- note that diff between those two files may be quite large, as
ApiDefinition.cshas been manually edited to ensure correct compilation and correct exposure of all native SDK features. Focus only on adding new recognizers and parsers. Usually it shuold not be necessary to add other classes.
- note that diff between those two files may be quite large, as
-
Open
Binding/Forms/BlinkID.Forms/BlinkID.Forms.slnsolution -
From
iOSBindingproject removeMicroBlink.bundleand re-add it back- this will ensure that all new resources from new bundle are correctly added to the project
- also make sure that all resources within added
MicroBlink.bundlehaveBuildActionset toBundleResource
-
Right-click the
iOSBindingproject, selectOptions, underNuGet Packagesection selectMetadata -
Update
Versionon tabGeneral -
Update
Release noteson tabDetails -
Rebuild the
iOSBindingproject and fix any compile errors that may have been introduced in steps 4. and 5.
- Ensure that both Android and iOS native binding libraries have been updated as explained above
- Open
Binding/Forms/BlinkID.Forms/BlinkID.Forms.slnsolution - Right-click the
BlinkID.Forms.Coreproject, selectOptions, underNuGet Packagesection selectMetadata - Update
Versionon tabGeneral - Update
Release noteson tabDetails - Do the same for
BlinkID.Forms.Android,BlinkID.Forms.iOSandBlinkID.Forms.NuGetprojects - in
BlinkID.Forms.Coreadd interfaces for new functionality (e.g. new recognizer) - add implementation for those interfaces in
BlinkID.Forms.AndroidandBlinkID.Forms.iOSprojects - rebuild both
BlinkID.Forms.Core,BlinkID.Forms.AndroidandBlinkID.Forms.iOSprojects
- Ensure that all projects have been updated as described above
- this includes Android and iOS native binding libraries and Xamarin Forms core and platform implementations libraries
- Open
Binding/Forms/BlinkID.Forms/BlinkID.Forms.slnsolution - Make sure
Releasebuild type is selected inVisual Studio - Right-click on
BlinkID.Forms.NuGetproject and selectCreate NuGet package- all projects will be built and their respective NuGet packages will be created in their
bin/Releasefolder
- all projects will be built and their respective NuGet packages will be created in their
- Upload packages to NuGet
This section describes how to create your scan activity with BlinkID SDK, natively in Android and wrap it to Xamarin. For that purpose, we have prepared AndroidCustomUI sample.
Steps to wrap custom functionality to Xamarin:
- Implement it natively for Android - create Android library:
- make sure that you are not using any resources from the BlinkID Android SDK in resource files inside your library, otherwise, you will get compile errors while generating Xamarin bindings from Android library
- we have created BlinkIDWrapper Android Studio project which contains LibBlinkIDWrapper Android library module with custom scan activity
- Build .aar archive from the library module:
- we have built
LibBlinkIDWrapper-release.aarfrom our Android library module
- we have built
- Create a new Xamarin Bindings Library for Android:
- add a dependency to
BlinkID.Android.Bindingnuget package - add
.aartoJarsfolder and set the Build Action for.aarto LibraryProjectZip - we have prepared CustomUIBinding project inside CustomUISample solution
- add a dependency to
- You can use the Bindings Library in the application project:
- first, add a reference to the created Bindings Library
- add a dependency to
BlinkID.Android.Binding - we have prepared sample application project CustomUIApp inside CustomUISample solution