BlinkID mobile SDK

Accelerate user onboarding by turning any mobile camera into an AI-powered identity document scanner. All processing is done locally on device, keeping all your sensitive user data in one place. We've wrapped our SDK for each development framework, so that you can integrate and tailor BlinkID to your application in minutes. Currently available for iOS, Android, React Native, Xamarin, and Cordova.

Learn more about BlinkID

View full list of supported documents

Get started with our SDK free trial

Start developing your app with BlinkID SDK — sample code, documentation, size reports and supported languages are available on our Github repositories below. Please follow the implementation guidance carefully, star and watch relevant repositories, and take the time to play around with BlinkID. Get your free trial license key by creating an account in our Developer Dashboard (no credit card required).

Try our free demo app and watch the scanning magic happen.

If you'd like to give BlinkID a go without coding, simply download the free Microblink Vision demo app.

Integration sample codes

Copy to clipboard
/**
 * Set your license file. The recommended way is extending the Android Application class
 * and setting the license file in its onCreate callback.
 * Register on our dashboard to get the license key for your app.
 */
public class MyApplication extends Application {
    @Override
    public void onCreate() {
        MicroblinkSDK.setLicenseFile("path/to/license/file/within/assets/dir", this);
    }
}

public class MyActivity extends Activity {
    private BlinkIdRecognizer mRecognizer;
    private RecognizerBundle mRecognizerBundle;
    
    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        
        // setup views, as you would normally do in onCreate callback
        
        // create BlinkIdRecognizer for scanning supported document
        // see https://bit.ly/2PkmUmY for options
        mRecognizer = new BlinkIdRecognizer();
        
        // bundle recognizers into RecognizerBundle
        mRecognizerBundle = new RecognizerBundle(mRecognizer);
    }
    
    public void startScanning() {
        // Settings for BlinkIdActivity
        BlinkIdUISettings settings = new BlinkIdUISettings(mRecognizerBundle);
    
        // tweak settings as you wish
    
        // Start activity
        ActivityRunner.startActivityForResult(this, MY_REQUEST_CODE, settings);
    }
    
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    
        if (requestCode == MY_REQUEST_CODE) {
            if (resultCode == Activity.RESULT_OK && data != null) {
                // load the data into all recognizers bundled within your RecognizerBundle
                mRecognizerBundle.loadFromIntent(data);
            
                // now every recognizer object that was bundled within RecognizerBundle
                // has been updated with results obtained during scanning session
            
                // you can get the result by invoking getResult on recognizer
                BlinkIdRecognizer.Result result = mRecognizer.getResult();
                if (result.getResultState() == Recognizer.Result.State.Valid) {
                    // result is valid, you can use it however you wish
                }
            }
        }
    }
}
Copy to clipboard
/**
 * Set your license file. The recommended way is extending the Android Application class
 * and setting the license file in its onCreate callback.
 * Register on our dashboard to get the license key for your app.
 */
class BlinkIdSampleApp : Application() {
    override fun onCreate() {
        MicroblinkSDK.setLicenseFile("path/to/license/file/within/assets/dir", this);
    }
}

class MainActivity : Activity() {
    private lateinit var recognizer: BlinkIdCombinedRecognizer
    private lateinit var recognizerBundle: RecognizerBundle
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        
        // setup views, as you would normally do in onCreate callback
        
        // create BlinkIdCombinedRecognizer for scanning supported document
        // see https://bit.ly/3byPtoN for options
        recognizer = BlinkIdCombinedRecognizer()
        
        // bundle recognizers into RecognizerBundle
        recognizerBundle = RecognizerBundle(recognizer)
    }
    
    fun startScanning() {
        // Settings for BlinkIdActivity
        val settings = BlinkIdUISettings(recognizerBundle)
    
        // tweak settings as you wish
    
        // Start activity
        ActivityRunner.startActivityForResult(this, MY_REQUEST_CODE, settings)
    }
    
    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data);
    
        if (requestCode == MY_REQUEST_CODE) {
            if (resultCode == Activity.RESULT_OK && data != null) {
                // load the data into all recognizers bundled within your RecognizerBundle
                recognizerBundle.loadFromIntent(data)
            
                // now every recognizer object that was bundled within RecognizerBundle
                // has been updated with results obtained during scanning session
            
                // you can get the result from the recognizer
                val result = recognizer.result
                if (result.resultState == Recognizer.Result.State.Valid) {
                    // result is valid, you can use it however you wish
                }
            }
        }
    }
}
Copy to clipboard
import UIKit
import Microblink

class ViewController: UIViewController {
    
    var blinkIdRecognizer : MBBlinkIdCombinedRecognizer?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        MBMicroblinkSDK.sharedInstance().setLicenseResource("blinkid-license", withExtension: "txt", inSubdirectory: "", for: Bundle.main)
    }

    @IBAction func didTapScan(_ sender: AnyObject) {
        
        /** Create BlinkID recognizer */
        self.blinkIdRecognizer = MBBlinkIdCombinedRecognizer()
        self.blinkIdRecognizer?.returnFullDocumentImage = true;
        
        /** Create settings */
        let settings : MBBlinkIdOverlaySettings = MBBlinkIdOverlaySettings()
        
        /** Crate recognizer collection */
        let recognizerList = [self.blinkIdRecognizer!]
        let recognizerCollection : MBRecognizerCollection = MBRecognizerCollection(recognizers: recognizerList)
        
        /** Create your overlay view controller */
        let blinkIdOverlayViewController : MBBlinkIdOverlayViewController = MBBlinkIdOverlayViewController(settings: settings, recognizerCollection: recognizerCollection, delegate: self)
        
        /** Create recognizer view controller with wanted overlay view controller */
        let recognizerRunneViewController : UIViewController = MBViewControllerFactory.recognizerRunnerViewController(withOverlayViewController: blinkIdOverlayViewController)
        recognizerRunneViewController.modalPresentationStyle = .fullScreen
        
        /** Present the recognizer runner view controller. You can use other presentation methods as well (instead of presentViewController) */
        self.present(recognizerRunneViewController, animated: true, completion: nil)
    }
}

extension ViewController: MBBlinkIdOverlayViewControllerDelegate {
    
    func blinkIdOverlayViewControllerDidFinishScanning(_ blinkIdOverlayViewController: MBBlinkIdOverlayViewController, state: MBRecognizerResultState) {
  
        /** You first pause the scanning to handle the result */
        blinkIdOverlayViewController.recognizerRunnerViewController?.pauseScanning()
        
        /** You first check if you got a valid result for the recognizer */
        if (self.blinkIdRecognizer?.result.resultState == MBRecognizerResultState.valid) {
            
            /** result is valid, you can use it however you wish */
            
            DispatchQueue.main.async {
                /** If you update the UI, you need to do it on the Main thread */
            }
        } else {
            /** If you didn't get a valid result, resume scanning */
            blinkIdOverlayViewController.recognizerRunnerViewController?.resumeScanningAndResetState(false)
        }
    }
    
    func blinkIdOverlayViewControllerDidTapClose(_ blinkIdOverlayViewController: MBBlinkIdOverlayViewController) {
        self.dismiss(animated: true, completion: nil)
    }
}
Copy to clipboard
#import "ViewController.h"
#import <Microblink/Microblink.h>

@interface ViewController () <MBBlinkIdOverlayViewControllerDelegate>

@property (nonatomic, strong) MBBlinkIdRecognizer *blinkIdRecognizer;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    /** First, set license key as soon as possible */
    [[MBMicroblinkSDK sharedInstance] setLicenseResource:@"blinkid-license" withExtension:@"txt" inSubdirectory:@"" forBundle:[NSBundle mainBundle]];
}

- (IBAction)didTapScan:(id)sender {
    
    MBBlinkIdOverlaySettings* settings = [[MBBlinkIdOverlaySettings alloc] init];
    
    /** Create BlinkID recognizer */
    self.blinkIdRecognizer = [[MBBlinkIdRecognizer alloc] init];
    self.blinkIdRecognizer.returnFullDocumentImage = YES;

    /** Create recognizer collection */
    MBRecognizerCollection *recognizerCollection = [[MBRecognizerCollection alloc] initWithRecognizers:@[self.blinkIdRecognizer]];
    
    MBBlinkIdOverlayViewController *overlayVC = [[MBBlinkIdOverlayViewController alloc] initWithSettings:settings recognizerCollection:recognizerCollection delegate:self];
    UIViewController<MBRecognizerRunnerViewController>* recognizerRunnerViewController = [MBViewControllerFactory recognizerRunnerViewControllerWithOverlayViewController:overlayVC];
    
    /** Present the recognizer runner view controller. You can use other presentation methods as well (instead of presentViewController) */
    [self presentViewController:recognizerRunnerViewController animated:YES completion:nil];
}

#pragma mark - MBBlinkIdOverlayViewControllerDelegate

- (void)blinkIdOverlayViewControllerDidFinishScanning:(MBBlinkIdOverlayViewController *)blinkIdOverlayViewController state:(MBRecognizerResultState)state {
    
    NSString *message = nil;
    NSString *title = nil;
    
    // first, pause scanning until we process all the results
    [blinkIdOverlayViewController.recognizerRunnerViewController pauseScanning];
    
    // check for valid state
    if (state == MBRecognizerResultStateValid) {
        
        title = @"BlinkID";
        message = self.blinkIdRecognizer.result.description;
        
        dispatch_async(dispatch_get_main_queue(), ^{
            UIAlertController* alert = [UIAlertController alertControllerWithTitle:title
                                       message:message
                                       preferredStyle:UIAlertControllerStyleAlert];

            UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
                                           handler:^(UIAlertAction * action) {}];

            [alert addAction:defaultAction];
            [self presentViewController:alert animated:YES completion:nil];
        });
    }
}

- (void)blinkIdOverlayViewControllerDidTapClose:(MBBlinkIdOverlayViewController *)blinkIdOverlayViewController {
    // As scanning view controller is presented full screen and modally, dismiss it
    [self dismissViewControllerAnimated:YES completion:nil];
}

@end
Copy to clipboard
// Cordova sample
var app = {
    // Application Constructor
    initialize: function() {
        this.bindEvents();
    },
    
    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
    },

    onDeviceReady: function() {
        app.receivedEvent('deviceready');

        // BlinkIdCombinedRecognizer automatically classifies different document types and scans the data from
        // the supported document
        var blinkIdCombinedRecognizer = new cordova.plugins.BlinkID.BlinkIdCombinedRecognizer();
        blinkIdCombinedRecognizer.returnFullDocumentImage = true;
        blinkIdCombinedRecognizer.returnFaceImage = true;

        var blinkidOverlaySettings = new cordova.plugins.BlinkID.BlinkIdOverlaySettings();

        // create RecognizerCollection from any number of recognizers that should perform recognition
        var recognizerCollection = new cordova.plugins.BlinkID.RecognizerCollection([blinkIdCombinedRecognizer]);

        // set license keys for your applicationId/bundleId
        var licenseKeys = {
            android: 'android_license_key_string',
            ios: 'ios_license_key_string'
        };

        scanButton.addEventListener('click', function() {
            cordova.plugins.BlinkID.scanWithCamera(
            
                // Register the callback handler
                function callback(cancelled) {

                    if (cancelled) {
                        // handle cancelled scanning
                        return;
                    }
                    
                    // if not cancelled, every recognizer will have its result property updated

                    if (blinkIdCombinedRecognizer.result.resultState == cordova.plugins.BlinkID.RecognizerResultState.valid) {
                        // use blinkIdCombinedRecognizer.result
                    }
                },
                
                // Register the error callback
                function errorHandler(err) {
                    alert('Error: ' + err);
                },

                blinkidOverlaySettings, recognizerCollection, licenseKeys
            );
        });

    },
    // Update DOM on a Received Event
    receivedEvent: function(id) {
        console.log('Received Event: ' + id);
    }
};
Copy to clipboard
import React, { Component } from 'react';
import * as BlinkIDReactNative from 'blinkid-react-native';
import {
    Platform,
    //... yor imports
} from 'react-native';

const licenseKey = Platform.select({
    // iOS license key for your bundle ID
    ios: 'ios_license_key_string',
    // android license key for your applicationID
    android: 'android_license_key_string'
})

export default class BlinkIDReactNativeApp extends Component {
    constructor(props) {
        super(props);
    }

    async scan() {
        try {

            // BlinkIdCombinedRecognizer automatically classifies different document types and scans the data from
            // the supported document
            var blinkIdCombinedRecognizer = new BlinkIDReactNative.BlinkIdCombinedRecognizer();
            blinkIdCombinedRecognizer.returnFullDocumentImage = true;
            blinkIdCombinedRecognizer.returnFaceImage = true;

            const scanningResults = await BlinkIDReactNative.BlinkID.scanWithCamera(
                new BlinkIDReactNative.BlinkIdOverlaySettings(),
                new BlinkIDReactNative.RecognizerCollection([blinkIdCombinedRecognizer]),
                licenseKey
            );

            if (scanningResults) {

                for (let i = 0; i < scanningResults.length; ++i) {
                    let result = scanningResults[i];
                    if (result instanceof BlinkIDReactNative.BlinkIdCombinedRecognizerResult) {
                        // do something with the result
                    }
                }
            }
        } catch (error) {
            console.log(error);
        }
    }
    // ...
}
Copy to clipboard
using System;
using Microblink.Forms.Core;
using Microblink.Forms.Core.Overlays;
using Microblink.Forms.Core.Recognizers;

using Xamarin.Forms;

namespace BlinkIDApp
{
    public partial class BlinkIDPage : ContentPage
    {
        /// <summary>
        /// Microblink scanner is used for scanning the identity documents.
        /// </summary>
        IMicroblinkScanner blinkID;

        /// <summary>
        /// BlinkID recognizer will be used for automatic detection and data extraction from the supported document.
        /// </summary>
        IBlinkIdRecognizer blinkidRecognizer;

        public BlinkIDPage ()
        {
            InitializeComponent ();

            // before obtaining any of the recognizer's implementations from DependencyService, it is required
            // to obtain instance of IMicroblinkScanner and set the license key.
            // Failure to do so will crash your app.
            var microblinkFactory = DependencyService.Get<IMicroblinkScannerFactory>();

            // license keys are different for iOS and Android and depend on iOS bundleID/Android application ID
            // in your app, you may obtain the correct license key for your platform via DependencyService from
            // your Droid/iOS projects
            string licenseKey;

            // both these license keys are demo license keys for bundleID/applicationID com.microblink.xamarin.blinkid
            if (Device.RuntimePlatform == Device.iOS)
            {
                licenseKey = "<ios_license_key_string>"
            else
            {
                licenseKey = "<android_license_key_string>";
            }

            // since DependencyService requires implementations to have default constructor, a factory is needed
            // to construct implementation of IMicroblinkScanner with given license key
            blinkID = microblinkFactory.CreateMicroblinkScanner(licenseKey);

            // subscribe to scanning done message
            MessagingCenter.Subscribe<Messages.ScanningDoneMessage> (this, Messages.ScanningDoneMessageId, (sender) => {
                ImageSource faceImageSource = null;
                ImageSource fullDocumentImageSource = null;
                ImageSource successFrameImageSource = null;

                string stringResult = "No valid results.";

                // if user cancelled scanning, sender.ScanningCancelled will be true
                if (sender.ScanningCancelled)
                {
                    stringResult = "Scanning cancelled";
                }
                else
                {
                    // otherwise, one or more recognizers used in RecognizerCollection (see StartScan method below)
                    // will contain result

                    // if specific recognizer's result's state is Valid, then it contains data recognized from image
                    if (blinkidRecognizer.Result.ResultState == RecognizerResultState.Valid)
                    {
                        var blinkidResult = blinkidRecognizer.Result;
                        stringResult =
                            "BlinkID recognizer result:\n" +
                            "FirstName: " + blinkidResult.FirstName + "\n" +
                            "LastName: " + blinkidResult.LastName + "\n" +
                            "Address: " + blinkidResult.Address + "\n" +
                            "DocumentNumber: " + blinkidResult.DocumentNumber + "\n" +
                            "Sex: " + blinkidResult.Sex + "\n";
                        var dob = blinkidResult.DateOfBirth;
                        if (dob != null)
                        {
                            stringResult +=
                                "DateOfBirth: " + dob.Day + "." +
                                                  dob.Month + "." +
                                                  dob.Year + ".\n";
                        }
                        var doi = blinkidResult.DateOfIssue;
                        {
                            stringResult +=
                                "DateOfIssue: " + doi.Day + "." +
                                                  doi.Month + "." +
                                                  doi.Year + ".\n";

                        }
                        var doe = blinkidResult.DateOfExpiry;
                        if (doe != null)
                        {
                            stringResult +=
                                "DateOfExpiry: " + doe.Day + "." +
                                                   doe.Month + "." +
                                                   doe.Year + ".\n";

                        }
                        // there are other fields to extract

                        fullDocumentImageSource = blinkidResult.FullDocumentImage;
                    }
                }

                // updating the UI must be performed on main thread
                Device.BeginInvokeOnMainThread (() => {
                    resultsEditor.Text = stringResult;
                    fullDocumentImage.Source = fullDocumentImageSource;
                    successScanImage.Source = successFrameImageSource;
                    faceImage.Source = faceImageSource;
                });

            });

        }

        /// <summary>
        /// Button click event handler that will start the scanning procedure.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        void StartScan (object sender, EventArgs e)
        {
            // license keys must be set before creating Recognizer, othervise InvalidLicenseKeyException will be thrown
            // the following code creates and sets up implementation of MrtdRecognizer
            blinkidRecognizer = DependencyService.Get<IBlinkIdRecognizer>(DependencyFetchTarget.NewInstance);
            blinkidRecognizer.ReturnFullDocumentImage = true;

            // first create a recognizer collection from all recognizers that you want to use in recognition
            // if some recognizer is wrapped with SuccessFrameGrabberRecognizer, then you should use only the wrapped one
            var recognizerCollection = DependencyService.Get<IRecognizerCollectionFactory>().CreateRecognizerCollection(blinkidRecognizer);

            // using recognizerCollection, create overlay settings that will define the UI that will be used
            // there are several available overlay settings classes in Microblink.Forms.Core.Overlays namespace
            // document overlay settings is best for scanning identity documents
            var blinkidOverlaySettings = DependencyService.Get<IBlinkIdOverlaySettingsFactory>().CreateBlinkIdOverlaySettings(recognizerCollection);

            // start scanning
            blinkID.Scan(blinkidOverlaySettings);
        }
    }
}