> For the complete documentation index, see [llms.txt](https://valify.gitbook.io/valify-ios-sdk-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://valify.gitbook.io/valify-ios-sdk-documentation/dockit/android-native-sdk/implementation-guide.md).

# Implementation Guide

### Authentication

A unique access token should be created upon each SDK entry. In order to generate an access token, please refer to Valify's [Authentication](https://valify.gitbook.io/documentation/apis/oauth-token) Documentation.

{% hint style="warning" %}
**Security Warning:** For improved security, consider implementing the access token fetching logic outside the Activity. This helps keep sensitive credentials secure and reduces potential exposure within the Activity/Fragment code.
{% endhint %}

### Initialization

Declare the following variables

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
private lateinit var docKitBuilder: VIDVDocKitConfig.Builder
```

{% endtab %}

{% tab title="Java" %}

```java
private VIDVDocKitConfig.Builder docKitBuilder;
```

{% endtab %}
{% endtabs %}

Initialize your SDK in your activity or fragment as follows

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
docKitBuilder = VIDVDocKitConfig.Builder()
```

{% endtab %}

{% tab title="Java" %}

```java
docKitBuilder= new VIDVDocKitConfig.Builder();
```

{% endtab %}
{% endtabs %}

### Configurations

The SDK builder is separated into two components.

{% hint style="info" %}
Make sure that you fetched the **access token** successfully before passing it to the Builder object.
{% endhint %}

#### Required Configurations

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
docKitBuilder
    .setBaseUrl("Base Url") // add your actual base url
    .setAccessToken("Access Token") // add the fetched access token here
    .setBundleKey("Bundle Key") // add your actual bundle key
    .setDocumentType(VIDVDocKitDocType.<your chosen doc type>()) //avaliable doc types: passport - egyNID - tunNID -dzaNID
```

{% endtab %}

{% tab title="Java" %}

```java
docKitBuilder
.setBaseUrl("Base Url"); //add your actual base url
.setAccessToken("Access Token"); //add the fetched access token here
.setBundleKey("Bundle Key"); //add your actual bundle key
.setDocumentType(VIDVDocKitDocType.passport());  //avaliable doc types: passport - egyNID - tunNID - dzaNID
```

{% endtab %}
{% endtabs %}

#### Optional Configurations

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
docKitBuilder
.setLanguage("en") // or "ar"
.setCollectUserInfo(true) // enable location permissions if true
.previewCapturedImage(true) // show preview of captured image
.reviewData(true) // show a review screen before finishing

.setCaptureMode(VIDVCaptureMode.<your_chosen_capture_mode>.INSTANCE) //Choose from MANUAL , AUTOMATIC, AUTO_AFTER(7)
.setExtras(
            mapOf(
                "advancedConfidence" to true,
                "professionAnalysis" to true,
                "documentVerificationPlus" to true
            )
        ) // only valid for Egy NID docuemnt
        

// UI Customization
.setPrimaryColor("#FFA500".toColorInt())
.setLogo(VIDVLogo.ResourceLogo(R.drawable.logo))
//or
.setLogo(VIDVLogo.ByteArrayLogo(byteArray))
//or
.setLogo(VIDVLogo.Empty()) // Hide logo

```

{% endtab %}

{% tab title="Java" %}

```java
docKitBuilder
.setLanguage("en"); // or "ar"
.setCollectUserInfo(true); 
.previewCapturedImage(true); // show preview of captured image
.reviewData(true); // show a review screen before finishing
.setCaptureMode(VIDVCaptureMode.<your_chosen_capture_mode>.INSTANCE); //Choose from MANUAL , AUTOMATIC, AUTO_AFTER(7)
.setExtras(extras); // attach the extras map

// UI Customization
.setPrimaryColor(android.graphics.Color.parseColor("#FFA500"));
.setLogo(new VIDVLogo.ResourceLogo(R.drawable.logo));
// OR:
.setLogo(new VIDVLogo.ByteArrayLogo(byteArray));
// OR:
.setLogo(new VIDVLogo.Empty());  // hide logo
```

{% endtab %}
{% endtabs %}

### Configurations Breakdown

1\. Sets the base URL used by the SDK to communicate with your backend APIs.

```kotlin
.setBaseUrl("Base Url") 
```

2\. Sets the access token required for authenticating SDK API requests.

```kotlin
.setAccessToken("Access Token") // add the fetched access token here
```

3\. Associates the session with your account using a unique bundle key.

```kotlin
.setBundleKey("Bundle Key") // add your actual bundle key
```

4\. Specifies the type of document to be captured by the SDK.

Available options:

* `passport()`
* `egyNID()`
* `tunNID()`
* `dzaNID()`

```kotlin
.setDocumentType(VIDVDocKitDocType.passport())
```

5\. Sets the interface language used throughout the SDK experience.

Supported languages:

* `"en"` for English
* `"ar"` for Arabic
* `"fr"` for French

```kotlin
.setLanguage("en")
```

6\. Enables the collection of user info like location. Requires location permission in manifest.

```kotlin
.setCollectUserInfo(true)
```

7\. Enables image preview after capture so users can confirm or retake it.

```kotlin
.previewCapturedImage(true)
```

8\. Displays a data review screen before submitting the final result.

```kotlin
.reviewData(true)
```

9\. Enables manual capture mode for users instead of automatic capture.

```kotlin
.setCaptureMode(VIDVCaptureMode.MANUAL.INSTANCE) //Allows manual capture fromthe beginning
.setCaptureMode(VIDVCaptureMode.AUTOMATIC.INSTANCE) //Allows Automatic capture from the beginning
.setCaptureMode(VIDVCaptureMode.AUTO_AFTER(<yourChosenTimeInSec>)) //Allows manual capture the configured time if the image wasn't auto-captured
```

10\. Sets your brand’s primary color in the SDK UI. Use a hex color strin&#x67;**.**

```kotlin
.setPrimaryColor(Color.parseColor("#FFA500"))
```

11\. Displays your logo in the SDK UI using a drawable resource from your app.

```kotlin
.setLogo(VIDVLogo.ResourceLogo(R.drawable.logo))
```

12\. Displays your logo using a byte array (e.g., from a file or server).

```kotlin
.setLogo(VIDVLogo.ByteArrayLogo(byteArray))
```

13\. Hides Valify's logo entirely from the SDK UI.

```kotlin
.setLogo(VIDVLogo.Empty())
```

14. Adds optional feature flags that enhance the SDK's processing capabilities.\
    These extras allow you to enable advanced functionalities during **EGY NID** document processing:

* **advancedConfidence** → Enables Physical manipulation detection
* **professionAnalysis** → Enables profession categorization
* **documentVerificationPlus** → Enables document validation

```java
.Map<String, Object> extras = new HashMap<>();
extras.put("advancedConfidence", true);
extras.put("professionAnalysis", true);
extras.put("documentVerificationPlus", true);
.setExtras(extras);
```

### Start SDK

\
Use the following code snippet to run the SDK

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
config.start(this, object : VIDVDocKitListener {
    override fun onDocKitResult(result: VIDVDocKitResponse) {
        when (result) {
            is VIDVDocKitResponse.Success -> {
                // Handle success
            }
            is VIDVDocKitResponse.ServiceFailure -> {
                // Handle failure
            }
            is VIDVDocKitResponse.BuilderError -> {
                // Handle builder error
            }
            is VIDVDocKitResponse.Exit -> {
                val step = result.step // screen where user exited
            }
        }
    }
})

```

{% endtab %}

{% tab title="Java" %}

```java
config.start(this, new VIDVDocKitListener() {
    @Override
    public void onDocKitResult(VIDVDocKitResponse result) {
        if (result instanceof VIDVDocKitResponse.Success) {
            // Handle success
        } else if (result instanceof VIDVDocKitResponse.ServiceFailure) {
            // Handle failure
        } else if (result instanceof VIDVDocKitResponse.BuilderError) {
            // Handle builder error
        } else if (result instanceof VIDVDocKitResponse.Exit) {
            VIDVDocKitResponse.Exit exitResult = (VIDVDocKitResponse.Exit) result;
            String step = exitResult.getStep(); // screen where user exited
        }
    }
});

```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://valify.gitbook.io/valify-ios-sdk-documentation/dockit/android-native-sdk/implementation-guide.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
