SDK

Adding the SDK to your project

To add our SDK to your own application, you should add it to the build process of your application. Currently we only support doing this using Gradle.
Adding the SDK to your gradle build file consist of two steps:

Adding the repository

To add the repository to your gradle file, open the build.gradle file in your application. Make sure you use the build.grade of your project, not the top-level one.
Edit the repositories part of your build.gradle, so that it contains the following:

                
maven {
    credentials {
        username 'ExampleUsername'
        password 'ExamplePassword'
    }
    url "https://custom-ocr.klippa.com/sdk/android/maven"
}
maven { url "https://jitpack.io" }
                
            

We add jitpack.io because some of our dependencies are hosted there. If your build.gradle already contains jitpack.io, don't add it.
The full repositories section of your build.gradle might look like this now:

                
repositories {
    jcenter()
    maven {
        credentials {
            username 'ExampleUsername'
            password 'ExamplePassword'
        }
        url "https://custom-ocr.klippa.com/sdk/android/maven"
    }
    maven { url "https://jitpack.io" }
}
                
            

Adding the dependency

Edit the dependencies part of your build.gradle, so that it contains the following:

                
implementation 'com.klippa:identity_verification:0.6.5'
                
            

The full dependencies section of your build.gradle might look like this now:

                
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.klippa:identity_verification:0.6.5'
}
                
            

When you build your app now, it should download our library as dependency, and with that all dependencies of our library.

Creating sessions

Before you can start using the identity verification you need to generate a session token in your backend. You can then start the session using your newly generated token. Once the session has been completed you can collect the files and data read by the OCR.

Starting the identity verification

To start the identity verification, import our package:

                
// Add to the top of your file
import com.klippa.identity_verification.modules.base.IdentityBuilder;
                
            

Then start our session from your own Activity, be sure that you implemented `IdentityBuilder.IdentityBuilderListener`:

Java version

                
public class MainActivity extends AppCompatActivity implements IdentityBuilder.IdentityBuilderListener {
    // Call this function from a button press.
    private void startIdentityVerification() {
        // @todo: get a session token from the API through your backend here.

        // Launch the Identity Verification session.
        IdentityBuilder builder = new IdentityBuilder(this, "{insert-session-token-here}");
        builder.startSession(this);
    }

    @Override
    public void canceled() {
        // User canceled, handle user interaction.
        Log.w("KlippaIdentityVerification", "canceled");
    }

    @Override
    public void finishedWithSuccess() {
        // User finished with success, check result using API.
        Log.w("KlippaIdentityVerification", "finished with success");
    }

    @Override
    public void contactSupportPressed() {
        // User tapped the get Support button after they failed to verify.
        Log.w("KlippaIdentityVerification", "support button pressed");
    }
}
                
            

Kotlin version

                
class MainActivity : AppCompatActivity(), IdentityBuilder.IdentityBuilderListener {
    fun startIdentityVerification() {
        // @todo: get a session token from the API through your backend here.

        // Launch the Identity Verification session.
        val builder =
                IdentityBuilder(
                        this, "{insert-session-token-here}"
                )
        builder.startSession(this)
    }

    override fun canceled() {
        // User canceled, handle user interaction.
        TODO("Not yet implemented")
    }

    override fun finishedWithSuccess() {
        // User finished with success, check result using API.
        TODO("Not yet implemented")
    }

    override fun contactSupportPressed() {
        // User tapped the get Support button after they failed to verify.
        TODO("Not yet implemented")
    }
}
                
            

Customizing the session

The SDK has a few customizing settings, the following methods are available:

Java version

                    
IdentityBuilder.Colors colors = new IdentityBuilder.Colors();
colors.textColor = getResources().getColor(R.color.black);
colors.buttonSuccessColor = getResources().getColor(android.R.color.holo_green_light);
colors.buttonErrorColor = getResources().getColor(android.R.color.holo_red_dark);
colors.buttonOtherColor = getResources().getColor(android.R.color.holo_orange_light);
colors.backgroundColor = getResources().getColor(android.R.color.holo_red_light);
colors.progressBarBackground = getResources().getColor(android.R.color.holo_orange_light);
colors.progressBarForeground = getResources().getColor(android.R.color.holo_orange_dark);
builder.setColors(colors);

IdentityBuilder.Fonts fonts = new IdentityBuilder.Fonts();
fonts.font = R.font.avenir_black;
fonts.boldFont = R.font.avenir_black;
builder.setFonts(fonts);

// We support English, Dutch and Spanish.
builder.language = IdentityBuilder.KIVLanguage.English;
// The extracted data keys that will be shown to the user after document pictures are processed.
Default value:
List<String> includeList = new ArrayList<>(Arrays.asList(
    "DateOfExpiry",
    "DateOfIssue",
    "DocumentNumber",
    "DocumentSubtype",
    "DocumentType",
    "Face",
    "Gender",
    "GivenNames",
    "Height",
    "IssuingCountry",
    "IssuingInstitution",
    "Nationality",
    "PersonalNumber",
    "PlaceOfBirth",
    "Residency",
    "Signature",
    "Surname"
));
builder.includeList = includeList;

// The extracted data keys that will be hidden for the user after document pictures are processed.
// Default value (empty):
builder.excludeList = new ArrayList<>();
                    
                

Kotlin version

                    
builder.colors.textColor = getResources().getColor(R.color.black)
builder.colors.buttonSuccessColor = getResources().getColor(android.R.color.holo_green_light)
builder.colors.buttonErrorColor = getResources().getColor(android.R.color.holo_red_dark)
builder.colors.buttonOtherColor = getResources().getColor(android.R.color.holo_orange_light)
builder.colors.backgroundColor = getResources().getColor(android.R.color.holo_red_light)
builder.colors.progressBarBackground = getResources().getColor(android.R.color.holo_orange_light)
builder.colors.progressBarForeground = getResources().getColor(android.R.color.holo_orange_dark)

builder.fonts.font = R.font.avenir_black
builder.fonts.boldFont = R.font.avenir_black

// We support English, Dutch and Spanish.
builder.language = IdentityBuilder.KIVLanguage.English

// The extracted data keys that will be shown to the user after document pictures are processed.
Default value:
builder.includeList = mutableListOf(
    "DateOfBirth",
    "DateOfIssue",
    "DocumentNumber",
    "DocumentSubtype",
    "DocumentType",
    "Face",
    "Gender",
    "GivenNames",
    "Height",
    "IssuingCountry",
    "IssuingInstitution",
    "Nationality",
    "PersonalNumber",
    "PlaceOfBirth",
    "Residency",
    "Signature",
    "Surname"
)

// The extracted data keys that will be hidden for the user after document pictures are processed.
// Default value (empty):
builder.excludeList = mutableListOf()
                    
                

APK size / APK splitting

Because our SDK includes OpenCV, which includes native code which in turn generates a native library (.so file) for every architecture, the APK size can increase quite a bit by using our SDK.
To minimize the impact of the SDK on your app size, you can enable APK splitting in your build.grade, like this:

                
android {
    // Other options
    splits {
       abi {
           enable true
           universalApk false
           reset()
           include 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
       }
    }
    // Other options
}
                
            

In our example app (which contains not much more than the SDK), this resulted in the following APK files:

  • arm64-v8a.apk: 28MB
  • armeabi-v7a.apk: 15.2MB
  • x86_64.apk: 29.1MB
  • x86.apk: 28.4MB

While creating a single APK file creates a file that is 100.8MB, since most phones are ARM, on average APK splitting will result in a 45MB smaller APK, in those cases the SDK will add between 47-61MB to the APK size.

Please note that all APK files should be signed and uploaded to the Play Store to get a release that works on all devices.

JavaDoc

The JavaDoc of the latest version is available for download here.

Versions

The following versions are available:

Version Gradle dependency JavaDoc
0.6.5 implementation 'com.klippa:identity_verification:0.6.5' Download
0.6.4 implementation 'com.klippa:identity_verification:0.6.4' Download
0.6.3 implementation 'com.klippa:identity_verification:0.6.3' Download
0.6.2 implementation 'com.klippa:identity_verification:0.6.2' Download
0.6.1 implementation 'com.klippa:identity_verification:0.6.1' Download
0.6.0 implementation 'com.klippa:identity_verification:0.6.0' Download
0.5.2 implementation 'com.klippa:identity_verification:0.5.2' Download
0.5.1 implementation 'com.klippa:identity_verification:0.5.1' Download
0.5.0 implementation 'com.klippa:identity_verification:0.5.0' Download
0.4.0 implementation 'com.klippa:identity_verification:0.4.0' Download
0.3.0 implementation 'com.klippa:identity_verification:0.3.0' Download
0.2.2 implementation 'com.klippa:identity_verification:0.2.2' Download
0.2.1 implementation 'com.klippa:identity_verification:0.2.1' Download
0.2.0 implementation 'com.klippa:identity_verification:0.2.0' Download
0.1.0 implementation 'com.klippa:identity_verification:0.1.0' Download
0.0.16 implementation 'com.klippa:identity_verification:0.0.16' Download

Changelog

0.6.5

  • Temporarily disabled ID model detection.

0.6.4

  • Added ability to add MRZ manually instead of using MRZ scanner.
  • Added model to detect ID for assistance when taking photo of ID.
  • Fixed issue where NFC PACE authentication always failed.

0.6.3

  • Updated masterList
  • Fixed issue where NFC PACE authentication failure was not being handled correctly.

0.6.2

  • Fixed issue where camera could fail to load after configuration changes.
  • Fixed issue where some classes where being de-initialized too early.
  • Fixed issue where continue button could be dismissed unintentionally.

0.6.1

  • Added touch to focus to MRZ scanner.
  • Increased scanning resolution on MRZ scanner.
  • Decreased MRZ scanner view finder size for improved detection.
  • Decreased scanning times on MRZ scanner.
  • Fixed issue where MRZ scanner stop unexpectedly with some passports.
  • Fixed issue where some errors were not parsed correctly.

0.6.0

  • NFC is no longer required in the AndroidManifest.
  • Added DeviceDoesNotSupportNFC to KlippaError which is returned when NFC is required but the device does support not it.
  • Added DeviceNFCDisabled to KlippaError which is returned when NFC is required but is disabled on the device.

0.5.2

  • Multiple validation errors can now be shown if necessary.

0.5.1

  • Added ability to disable Liveness detection by setting RequiredLivenessCount to 0.
  • Fixed issue where some colors were not being set correctly.
  • Fixed issue where bold font was not being set correctly.
  • Fixed issue where NFC could fail during authentication.

0.5.0

  • Added NFC Support. This can be enabled through the API by setting RequiredNFCScanCount to 1.
  • Fixed issue where ProGuard might remove used classes.
  • User is now prompted if environment is too dark/bright.
  • Decreased size of Liveness detection models.

0.4.0

  • Added Active and Passive Liveness detection during the selfie step, users will now have to complete 2 tasks (tilting their head in x direction) before the selfie is automatically taken.
  • Renamed finished() to identityVerificationFinished().
  • Renamed canceled() to identityVerificationCanceled(withError:).
  • Renamed contactSupportPressed to identityVerificationContactSupportPressed().

0.3.0

  • The RequiredFields option now enforces that fields are filled. A session cannot be completed successfully if one of the required fields is missing.
  • Increased quality of pictures taken.

0.2.2

  • Fixed issue where permission request could sometimes hide behind activity.
  • Changed kiv_no_camera_permission to always appear if no permission to camera was granted. (Before it only showed for 3.5 seconds)

0.2.1

  • Fixed issue where we no longer require parent app to request camera permissions and if necessary actively ask for permission.

0.2.0

  • Now uses production API by default (unless you’re making a test/debug build builder.isDebug = true). Please note that due to this change you will have also have to call the production API (https://custom-ocr.klippa.com) from your backend.

0.1.0

  • Adjusted document and selfie screen UI
  • Added callback for support button pressed contactSupportPressed()
  • Added ability to include/exclude data from data verification check screen with builder.includeList and builder.excludeList

0.0.15

  • Fix timeout handling
  • Fix Spanish error string

0.0.14

  • Minor translation improvements
  • Fix Identity Document file display

0.0.13

  • Fix activity not finishing with correct state.
  • Add Spanish as language
  • Change some English string values
  • Finish Dutch translation

0.0.12

  • Fix annotations not being loaded correctly breaking API usage.

0.0.8

  • Allow colors to be properly overwritten.

0.0.7

  • Fix a bug in Gradle that prevented our resources from being included.

0.0.6

  • Add getIntent method to be able to start the activity yourself. Don’t force usage of the listener.

0.0.5

  • Update minification to always include our own package name.

0.0.1

  • Initial version