New BlinkID v5 mobile SDK

BlinkID v5 is the most powerful SDK for intelligent data extraction from over 200 identity document types, including driving licenses, national IDs, passports, travel visas, and others. Information is extracted by scanning the MRZ (machine-readable zone), barcodes, or plain text from the documents. The SDK is currently available for iOS and Android, and cross-platforms are coming soon.

Go to BlinkID v5 product page

Code, documentation, and integration guide are available in our Github repositories below. Please star and watch relevant repositories, and take the time to test BlinkID v5. Get your free demo license key by creating an account in our developer dashboard (no credit card required).

Download free BlinkID demo app

Please note that the new BlinkID v5 is not yet a part of the demo app. We are working on the update. 

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: BlinkIdRecognizer
    private lateinit var recognizerBundle: RecognizerBundle
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        
        // setup views, as you would normally do in onCreate callback
        
        // create BlinkIdRecognizer for scanning supported document
        // see https://bit.ly/2PkmUmY for options
        recognizer = BlinkIdRecognizer()
        
        // 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 : MBBlinkIdRecognizer?
    
    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 = MBBlinkIdRecognizer()
        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)
        
        /** 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) {
        /** This is done on background thread */
        blinkIdOverlayViewController.recognizerRunnerViewController?.pauseScanning()
        
        var message: String = ""
        var title: String = ""
        
        if (self.blinkIdRecognizer?.result.resultState == MBRecognizerResultState.uncertain) {
            title = "BlinkID"
            
            let fullDocumentImage: UIImage! = self.blinkIdRecognizer?.result.fullDocumentImage?.image
            print("Got BlinkID image with width: \(fullDocumentImage.size.width), height: \(fullDocumentImage.size.height)")
            
            // Save the string representation of the code
            message = self.blinkIdRecognizer!.result.description
            
            /** Needs to be called on main thread beacuse everything prior is on background thread */
            DispatchQueue.main.async {
                // present the alert view with scanned results
                
                let alertController: UIAlertController = UIAlertController.init(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
                
                let okAction: UIAlertAction = UIAlertAction.init(title: "OK", style: UIAlertAction.Style.default,
                                                                 handler: { (action) -> Void in
                                                                    self.dismiss(animated: true, completion: nil)
                })
                alertController.addAction(okAction)
                blinkIdOverlayViewController.present(alertController, animated: true, completion: nil)
            }
        }
    }
    
    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');

        // BlinkIDRecognizer automatically classifies different document types and scans the data from
        // the supported document
        var blinkIdRecognizer = new cordova.plugins.BlinkID.BlinkIdRecognizer();
        blinkIdRecognizer.returnFullDocumentImage = true;
        blinkIdRecognizer.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([blinkIdRecognizer]);

        // 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 (blinkIdRecognizer.result.resultState == cordova.plugins.BlinkID.RecognizerResultState.valid) {
                        // use blinkIdRecognizer.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);
    }
};