# Cordova Blink ID Plugin

BlinkID is a part of family of SDKs developed by [MicroBlink](http://www.microblink.com) for optical text recognition, barcode scanning, ID document scanning and many others.

## Plugin

The purpose of this plugin is to leverage Hybrid Applications with BlinkID SDK features. With this plugin the users can read the Card ID within a Web Application.

As with all the cordova plugins, the plugin isn't available until the execution of `deviceready` event.

```javascript
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    // ...
}
```

## Supported Platforms

- iOS
- Android


## Installation
- Run the following command:

```shell
    cordova plugin add http://hlcbitbucket01:7990/scm/cordova/blinkid-plugin.git
``` 

# Blink ID

The `Blink ID Plugin` provides an easy way to read ID cards and get a JSON with the result in your a mobile app.

## Methods

- __readCardId__: Method to read ID Cards, passports and drivers licenses.


## readCardId

__Parameters__:

- __successCallback__: A callback that is passed when the service is started with success. _(Function)_

- __errorCallback__: A callback that executes if an error occurs retrieving the `Blink ID Plugin` readCardId. _(Function)_

### Example

```javascript
var success = function (r) {
    console.log(r);
}

var fail = function (error) {
    console.log(error);
}
    
    
var licenseKey = "YOUR_LICENSE";
    
cordova.plugins.blinkId.readCardId(success, fail, licenseKey);

```
---

The success callback gets a JSON object with the following contents:
```javascript
{
  "dateOfBirth" : "",
  "nationality" : "",
  "documentCode" : "",
  "sex" : "",
  "dateOfExpiry" : "",
  "issuer" : "",
  "primaryId" : "",
  "opt2" : "",
  "mrzText" : "",
  "isParsed" : "",
  "secondaryId" : "",
  "opt1" : "",
  "documentNumber" : ""
}
 
```

---
