# Enrolment Flow

In order to use our SDK you need an authorization token. Please check our API "[Authorisation](https://docs.uqudo.com/docs/kyc/uqudo-api/authorisation)" in this regard.

Add the following code at the start-up of your application to initialise the SDK:

```javascript
function traceCallback(result) {
	console.log('----Trace=' + result);
};
function success(result) {
	console.log('----Result=' + result);
};
function failure(error) {
	console.log('----Result=' + JSON.parse(error));
};

...
// On App startup
cordova.plugins.UqudoIdPlugin.init(traceCallback);
...
```

Use the below method for setting the locale of the application:

```javascript
...
cordova.plugins.UqudoIdPlugin.setLocale("<your locale eg. en, ar etc.>");
...
```

To check if a document supports enrollment, reading and facial recognition you can use the below methods:

```javascript
...
cordova.plugins.UqudoIdPlugin.isEnrollmentSupported(cordova.plugins.UqudoIdPlugin.DocumentType.UAE_ID, success, failure);
cordova.plugins.UqudoIdPlugin.isReadingSupported(cordova.plugins.UqudoIdPlugin.DocumentType.UAE_ID, success, failure);
cordova.plugins.UqudoIdPlugin.isFacialRecognitionSupported(cordova.plugins.UqudoIdPlugin.DocumentType.UAE_ID, success, failure);
...
```

Below, you can find an example on how to initiate the enrolment process for a passport enabling the reading through NFC and facial recognition:

```javascript
var doc = new cordova.plugins.UqudoIdPlugin.DocumentBuilder()
	.setDocumentType(cordova.plugins.UqudoIdPlugin.DocumentType.PASSPORT)
	.enableReading(new cordova.plugins.UqudoIdPlugin.ReadingConfigurationBuilder()
		.forceReadingIfSupported(true)
		.build()
	)
	.build();
var enrollObject =  new cordova.plugins.UqudoIdPlugin.EnrollmentBuilder()
	.setToken(token)
	.enableFacialRecognition(new cordova.plugins.UqudoIdPlugin.FacialRecognitionConfigurationBuilder().build())
	.setAppearanceMode(cordova.plugins.UqudoIdPlugin.AppearanceMode.SYSTEM)
	.add(doc)
	.build();
cordova.plugins.UqudoIdPlugin.enroll(enrollObject, success, failure);
```

In order to evaluate all the possible options please refer to paragraph [Enrolment Flow](https://docs.uqudo.com/docs/kyc/uqudo-sdk/integration/android/enrolment-flow). The JS interface is the porting of the JAVA one. In addition you can check UqudoIdPlugin.js inside the plugin folder or directly from your IDE.

If **successful**, the response is a JSON Web Signature (JWS). Please refer to section "[SDK result](https://docs.uqudo.com/docs/kyc/uqudo-sdk/sdk-result)" for further details.

In case of a **failure**, the callback returns the following object:

<table><thead><tr><th width="122">Property</th><th width="83">Type</th><th width="99">Optional</th><th width="96">Default</th><th>Description</th></tr></thead><tbody><tr><td>code</td><td>String</td><td>No</td><td>None</td><td>See <a href="../../android/enrolment-flow#handling-the-result">Handling the Result</a></td></tr><tr><td>message</td><td>String</td><td>Yes</td><td>null</td><td>Description of the error if any</td></tr><tr><td>task</td><td>String</td><td>Yes</td><td>null</td><td>See <a href="../../android/enrolment-flow#handling-the-result">Handling the Result</a></td></tr></tbody></table>

Please refer to section [Analytics](https://docs.uqudo.com/docs/kyc/uqudo-sdk/integration/android/analytics) for details.
