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:
To add the repository to your project, open the settings.gradle file in your application.
Edit the repositories part of your settings.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" }
maven {
credentials {
username = "ExampleUsername"
password = "ExamplePassword"
}
setUrl("https://custom-ocr.klippa.com/sdk/android/maven")
}
maven { setUrl("https://jitpack.io") }
We add jitpack.io because some of our dependencies are hosted there. If your
settings.gradle already contains jitpack.io, don't add it.
The full repositories section of your settings.gradle might look
like this now:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
maven {
credentials {
username 'ExampleUsername'
password 'ExamplePassword'
}
url "https://custom-ocr.klippa.com/sdk/android/maven"
}
maven { url "https://jitpack.io" }
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven {
credentials {
username = "ExampleUsername"
password = "ExamplePassword"
}
setUrl("https://custom-ocr.klippa.com/sdk/android/maven")
}
maven { setUrl("https://jitpack.io") }
}
}
Edit the dependencies part of your build.gradle, so that it contains the following:
implementation 'com.klippa:identity_verification:0.7.11'
implementation("com.klippa:identity_verification:0.7.11")
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.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
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.7.11'
}
dependencies {
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
implementation("com.klippa:identity_verification:0.7.11")
}
When you build your app now, it should download our library as dependency, and with that all dependencies of our library.
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.
To start the identity verification, import our package:
// Add to the top of your file
import com.klippa.identity_verification.modules.base.IdentitySession;
// Add to the top of your file
import com.klippa.identity_verification.modules.base.IdentitySession
Then start the session from your own Activity
public class MainActivity extends AppCompatActivity {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// @todo: get a session token from the API through your backend here.
IdentitySession identitySession = new IdentitySession("{your-session-token}");
yourButton.setOnClickListener(buttonView ->
startIdentitySession.launch(identitySession)
);
}
private final ActivityResultLauncher startIdentitySession = registerForActivityResult(new StartIdentitySession(),
sessionResultCode -> {
// switch over the `sessionResultCode` and handle accordingly.
}
);
}
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// @todo: get a session token from the API through your backend here.
val identitySession = IdentitySession("{your-session-token}")
yourButton.setOnClickListener {
startIdentitySession.launch(identitySession)
}
}
private val startIdentitySession = registerForActivityResult(StartIdentitySession()) { sessionCode ->
// switch over the `sessionCode` and handle accordingly.
}
}
When the SDK is finished it will return a IdentitySessionResultCode. The current session codes are:
Note: It's also possible to get a message from each IdentitySessionResultCode by calling message() on the sessionCode
The SDK has a few customizing settings, the following methods are available:
Add or edit the file android/app/src/main/res/values/colors.xml, add the following:
<color name="kiv_text_color">#FF0000</color>
<color name="kiv_background_color">#000000</color>
<color name="kiv_button_success_color">#4CAF50</color>
<color name="kiv_accent_color">#E91E63</color>
<color name="kiv_button_error_color">#673AB7</color>
<color name="kiv_button_other_color">#333333</color>
<color name="kiv_progress_bar_background_color">#00FFFF</color>
<color name="kiv_progress_bar_foreground_color">#9C27B0</color>
<color name="kiv_camera_success_background_color">#BBAC27</color>
You can also replace the fonts by adding the files:
android/app/src/main/res/font/kiv_font.ttf
android/app/src/main/res/font/kiv_font_bold.ttf
We currently support English, Dutch, German, French and Spanish.
Note: It's currently not possible to change the strings.
identitySession.language = IdentitySession.KIVLanguage.Dutch;
identitySession.language = IdentitySession.KIVLanguage.Dutch
To configure how often a user can attempt a task before the contact support button is shown to the user.
identitySession.retryThreshold = 1;
identitySession.retryThreshold = 1
To configure whether to show intro/success screens, add the following to the session:
identitySession.hasIntroScreen = true;
identitySession.hasSuccessScreen = true;
identitySession.hasIntroScreen = true
identitySession.hasSuccessScreen = true
The ability to automatically take a photo of the document when it passes all checks.
identitySession.enableAutoCapture = true;
identitySession.enableAutoCapture = true
You can edit the include list: the extracted data keys that will be shown to the user after document pictures are processed. Or the exclude list: the extracted data keys that will be hidden for 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"
));
identitySession.includeList = includeList;
// Default value (empty):
identitySession.excludeList = new ArrayList<>();
// Default value:
identitySession.includeList = mutableListOf(
"DateOfBirth",
"DateOfIssue",
"DocumentNumber",
"DocumentSubtype",
"DocumentType",
"Face",
"Gender",
"GivenNames",
"Height",
"IssuingCountry",
"IssuingInstitution",
"Nationality",
"PersonalNumber",
"PlaceOfBirth",
"Residency",
"Signature",
"Surname"
)
// Default value (empty):
identitySession.excludeList = mutableListOf()
You can edit the validation include list: the failed validations that are shown to the user.
Or the validation exclude list: the failed validations that are hidden from the user.
For more information regarding validations check out the API documentation.
// Default value:
List<String> validationIncludeList = new ArrayList<>(Arrays.asList(
"DetectFace",
"CompareFace",
"DetectSignature",
"CompareSignature",
"CheckRequiredField",
"MatchSidesFront",
"MatchSidesBack",
"FieldValidation",
"MatchVizMrz",
"MrzChecksum"
));
identitySession.kivValidationIncludeList = validationIncludeList;
// Default value (empty):
identitySession.kivValidationExcludeList = new ArrayList<>();
identitySession.kivValidationIncludeList = listOf(
"DetectFace",
"CompareFace",
"DetectSignature",
"CompareSignature",
"CheckRequiredField",
"MatchSidesFront",
"MatchSidesBack",
"FieldValidation",
"MatchVizMrz",
"MrzChecksum"
)
// Default value (empty):
identitySession.kivValidationExcludeList = mutableListOf()
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:
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.
The JavaDoc of the latest version is available for download here.
The following versions are available:
Version | Gradle dependency | JavaDoc |
---|---|---|
0.7.11 | implementation 'com.klippa:identity_verification:0.7.11' | Download |
0.7.10 | implementation 'com.klippa:identity_verification:0.7.10' | Download |
0.7.9 | implementation 'com.klippa:identity_verification:0.7.9' | Download |
0.7.8 | implementation 'com.klippa:identity_verification:0.7.8' | Download |
0.7.7 | implementation 'com.klippa:identity_verification:0.7.7' | Download |
0.7.6 | implementation 'com.klippa:identity_verification:0.7.6' | Download |
0.7.5 | implementation 'com.klippa:identity_verification:0.7.5' | Download |
0.7.4 | implementation 'com.klippa:identity_verification:0.7.4' | Download |
0.7.3 | implementation 'com.klippa:identity_verification:0.7.3' | Download |
0.7.2 | implementation 'com.klippa:identity_verification:0.7.2' | Download |
0.7.1 | implementation 'com.klippa:identity_verification:0.7.1' | Download |
0.7.0 | implementation 'com.klippa:identity_verification:0.7.0' | Download |
0.6.9 | implementation 'com.klippa:identity_verification:0.6.9' | Download |
0.6.8 | implementation 'com.klippa:identity_verification:0.6.8' | Download |
0.6.7 | implementation 'com.klippa:identity_verification:0.6.7' | Download |
0.6.6 | implementation 'com.klippa:identity_verification:0.6.6' | Download |
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 |
lateinit session
was called before being uninitialized.liveness
tasks.document_type
in FieldValidation
was setup when creating a session.French
and German
translations.autoCapture
photo taking indication; now just the border changes color.kiv_accent_color
.IdentitySessionResultCode
: INCORRECT_SESSION_SETUP
which will be used when the session was configured incorrectly.enableAutoCapture
on IdentitySession
.kivValidationIncludeList
and kivValidationExcludeList
which can be used to include/exclude validations.MrzChecksumValidation
was not being handled correctly.AllowPictureFallback
which can be configured when creating a session token.IdentityBuilder
has been renamed to IdentitySession
.IdentitySession
must be initialized using a session token
.StartIdentitySession()
contract which will now be used for starting the session.IdentitySessionResultCode
which returns the result of the IdentitySession
IdentityBuilderListener
in favor of StartIdentitySession()
.StartIdentitySession()
returns IdentitySessionResultCode
enum.KlippaError
in favor of IdentitySessionResultCode
.IdentityBuilder
please use resources
instead (see Customizing the identity verification
).retryThreshold
on IdentityBuilder
(default is 3). When this button is tapped identityVerificationContactSupportPressed()
is called and the session is ended.SkipPassportBackPicture
in the session configuration.PACE
authentication always failed.masterList
PACE
authentication failure was not being handled correctly.AndroidManifest
.DeviceDoesNotSupportNFC
to KlippaError
which is returned when NFC is required but the device does support not it.DeviceNFCDisabled
to KlippaError
which is returned when NFC is required but is disabled on the device.RequiredLivenessCount
to 0.RequiredNFCScanCount
to 1.ProGuard
might remove used classes.finished()
to identityVerificationFinished()
.canceled()
to identityVerificationCanceled(withError:)
.contactSupportPressed
to identityVerificationContactSupportPressed()
.kiv_no_camera_permission
to always appear if no permission to camera was granted. (Before it only showed for 3.5 seconds)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.contactSupportPressed()
builder.includeList
and builder.excludeList