1️⃣ Getting started

In this short guide, you will learn how to integrate the Keyless Document SDK in your Android or iOS mobile application. You will learn how to read the document machine readable zone - MRZ - and how to scan the NFC tag of the document.

Prerequisites

Make sure you have both required API keys, and the list of productions hosts from your Keyless contact:

  • YOUR_CLOUDSMITH_TOKEN to download the SDK from cloudsmith repository

  • KEYLESS_API_KEY to configure the mobile SDK

  • KEYLESS_HOSTS a list of node URLs. Urls in KEYLESS_HOSTS must NOT contain any trailing slashes /.

Review the Keyless SDK requirements:

Installation

  1. To allow Keyless to handle the result of registerForActivityResult, you must call Keyless from an Activity implementing ActivityResultCaller.

    Extend any androidX activity that implements the interface for you, for example let your Activity extend the generic ComponentActivity or the more widespread AppCompatActivity.

  2. If you use Proguard, add the following rules to your Proguard configuration file:

    # Keyless Proguard
    -keep class io.keyless.documentsdk.** {*;}
    -keepclassmembers class io.keyless.documentsdk.** {*;}
  3. In the the repositories section of the settings.gradle file of your Android application, add the following snippet, replacing YOUR_CLOUDSMITH_TOKEN with the CloudSmith token provided to you by Keyless.

    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()
            mavenCentral()
            maven {
                url "https://dl.cloudsmith.io/YOUR_CLOUDSMITH_TOKEN/keyless/partners/maven/"
            }
        }
    }
  4. In the dependencies block of your project build.gradle file, typically app/build.gradle, add:

    dependencies {
    // ...
    
    implementation 'io.keyless:keyless-document-sdk:+'
    }
  5. In the android block of your project build.gradle file, typically app/build.gradle, make sure you have the following options:

    android {
        // ...
    
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    
        // add the following only if you're using Kotlin
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }

Initialization

There is some initialization to do before you can use the Keyless Document SDK.

  1. Initialize the Keyless Document SDK in your Application class:

    // MainApplication
    override fun onCreate() {
        super.onCreate()
        // Initialize Keyless
        KeylessDocument.initialize(application = this) 
    }
  2. Add your application to the Manifest

    <application
        ...
        android:name=".MainApplication"
        ...
    </application>
  3. Configure the Keyless Document SDK:

    // MainActivity
    override fun onCreate() {
        super.onCreate()
        KeylessDocument.configure(
            KeylessDocument.Config(
                apiKey = KEYLESS_API_KEY,
                hostURl = KEYLESS_HOST,
            ),
        )
    }

Last updated

Was this helpful?