Skip to content

Kvalifika/kvalifika-kotlin-sample

Repository files navigation

Kvalifika SDK Kotlin Sample

Use Kvalifika SDK to easily integrate into your Android app

Table of content:

 

Installation

Please use minSdkVersion 21 in your build.gradle (Module) file

  Add following to project's main build.gradle file

allprojects {
    repositories {
        // Existing repositories, like google() and jcenter()
        maven { url 'https://s3.eu-central-1.amazonaws.com/com.kvalifika.sdk' }
    }
}

  To install Kvalifika Android SDK, add following to build.gradle (Module) file:

dependencies {
  // Insert line below to include our client library as a dependency.
  implementation 'com.kvalifika:sdk:0.5.3'
}

 

Initialize the SDK

import com.kvalifika.sdk.KvalifikaSDK
import com.kvalifika.sdk.KvalifikaSDKLocale
import com.kvalifika.sdk.KvalifikaSDKCallback
import com.kvalifika.sdk.KvalifikaSDKError

After that you need to initialize SDK with your appId.

class MainActivity : AppCompatActivity() {
	 private lateinit var sdk: KvalifikaSDK
 	 private val appId: String = "YOUR APP ID"

	 override fun onCreate(savedInstanceState: Bundle?) {
			super.onCreate(savedInstanceState)
			setContentView(R.layout.activity_main)

			sdk = KvalifikaSDK.Builder(this, appId)
					.locale(KvalifikaSDKLocale.EN)
					.build()
	 }
}

 

Start Verification

Call sdk.startSession() on button click event

class MainActivity : AppCompatActivity() {
	 private lateinit var sdk: KvalifikaSDK
 	 private val appId: String = "YOUR APP ID"

	 override fun onCreate(savedInstanceState: Bundle?) {
			super.onCreate(savedInstanceState)
			setContentView(R.layout.activity_main)

			sdk = KvalifikaSDK.Builder(this, appId)
					.locale(KvalifikaSDKLocale.GE)
					.build()

	 }

	 // Start verification on button click
	 fun onVerificationPress(view: View?) {
			sdk.startSession()
	 }
}

 

Handling Verifications

It's useful to know if a user has completed the verification flow or canceled it. For this, you can implement the callback methods.

 

Callback Methods

Method Description
onInitialize This callback method is triggered when SDK initializes.
onStart This callback method is triggered when user starts verification.
onFinish This callback method is triggered when user completes verification. Get session data here.
onError This callback method is triggered on error. Error Codes.
sdk.callback(object : KvalifikaSDKCallback {
    override fun onInitialize() {
        Log.d("MainActivity", "initialized")
    }

    override fun onStart(sessionId: String) {
        Log.d("MainActivity", "started")
    }

    override fun onFinish(sessionId: String) {
		// Fetch session data here from your server
    }

    override fun onError(error: KvalifikaSDKError, message: String?) {
        if(error == KvalifikaSDKError.INVALID_APP_ID) {
    		Log.d("MainActivity", "Invalid App ID")
    	}

        if (error == KvalifikaSDKError.USER_CANCELLED) {
            Toast.makeText(applicationContext, "User cancelled", Toast.LENGTH_LONG).show()
        }

        if (error == KvalifikaSDKError.TIMEOUT) {
            Toast.makeText(applicationContext, "Timeout", Toast.LENGTH_LONG).show()
        }

        if (error == KvalifikaSDKError.SESSION_UNSUCCESSFUL) {
            Toast.makeText(applicationContext, "Session failed", Toast.LENGTH_LONG).show()
        }

        if (error == KvalifikaSDKError.ID_UNSUCCESSFUL) {
            Toast.makeText(applicationContext, "ID scan failed", Toast.LENGTH_LONG).show()
        }

        if (error == KvalifikaSDKError.CAMERA_PERMISSION_DENIED) {
            Toast.makeText(applicationContext, "Camera permission denied", Toast.LENGTH_LONG).show()
        }

        if (error == KvalifikaSDKError.LANDSCAPE_MODE_NOT_ALLOWED) {
            Toast.makeText(applicationContext, "Landscape mode is not allowed", Toast.LENGTH_LONG).show()
        }

        if (error == KvalifikaSDKError.REVERSE_PORTRAIT_NOT_ALLOWED) {
            Toast.makeText(applicationContext, "Reverse portrait is not allowed", Toast.LENGTH_LONG).show()
        }

        if (error == KvalifikaSDKError.FACE_IMAGES_UPLOAD_FAILED) {
            Toast.makeText(applicationContext, "Could not upload face images", Toast.LENGTH_LONG).show()
        }

        if (error == KvalifikaSDKError.DOCUMENT_IMAGES_UPLOAD_FAILED) {
            Toast.makeText(applicationContext, "Could not upload Id card or passport images", Toast.LENGTH_LONG).show()
        }
	
	if (error == KvalifikaSDKError.NO_MORE_ATTEMPTS) {
            Toast.makeText(applicationContext, "You have reached maximum attempts", Toast.LENGTH_LONG).show()
        }

        if (error == KvalifikaSDKError.UNKNOWN_INTERNAL_ERROR) {
            Toast.makeText(applicationContext, "Unknown error happened", Toast.LENGTH_LONG).show()
        }
    }
})

 

Error Codes

Error Code Description
INVALID_APP_ID Kvalifika App Id is incorrect
USER_CANCELLED User cancelled before completing verification.
TIMEOUT Cancelled due to inactivity.
SESSION_UNSUCCESSFUL The Session was not performed successfully
ID_UNSUCCESSFUL The ID Scan was not performed successfully and identity document data was not generated.
CAMERA_PERMISSION_DENIED Camera is required but access prevented by user settings.
LANDSCAPE_MODE_NOT_ALLOWED Verification cancelled because device is in landscape mode.
REVERSE_PORTRAIT_NOT_ALLOWED Verification cancelled because device is in reverse portrait mode.
FACE_IMAGES_UPLOAD_FAILED Could not upload face images. Internal request failed.
DOCUMENT_IMAGES_UPLOAD_FAILED Could not upload ID card or passport images. Internal request failed.
NO_MORE_ATTEMPTS User has reached maximum limit of attempts
UNKNOWN_INTERNAL_ERROR Session failed because of an unhandled internal error.

 

UI Customizations

Appearance

You can customize logo and icons. Provide drawable resources.

sdk = KvalifikaSDK.Builder(this, appId)
	.locale(KvalifikaSDKLocale.EN)
	.logo(R.drawable.logo)
	.documentIcon(R.drawable.document_icon)
	.activeFlashIcon(R.drawable.flash_on)
	.inactiveFlashIcon(R.drawable_flash_off)
	.cancelIcon(R.drawable.cancel_icon)
	.build()

 

Language

You can set locale when initializing SDK Supported locales are:

Code Language
EN English
GE Georgian
RU Russian
SP Spanish
sdk = KvalifikaSDK.Builder(this, appId)
        .locale(KvalifikaSDKLocale.EN)
        .build()

 

Development Mode

Without specifying mode SDK uses https://api.kvalifika.com

With development mode ON SDK uses https://apistaging.kvalifika.com

sdk = KvalifikaSDK.Builder(this, appId)
        .development(true)
        .build()

 

ProGuard

If you are using ProGuard in release build add following options:

-keep class com.facetec.sdk.** { *; }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages