Identity Verification
getting started
mobile - client-side SDKs
Android

Verification Flow

1. Install the Gradle Plugin

To install the Preventor Android SDK, add the following to your project’s build.gradle file:
  1. 1.
    Use minSdkVersion 23 in your build.gradle (Module:app)
  2. 2.
    Add implementation 'com.preventor:preventor_sdk:0.1.213-alpha' to your dependencies.
  3. 3.
    Add repository depencencies in your build.gradle (Project Settings)
A complete build.gradlefile should look similar to the example below.
1
android {
2
// 1. Ensure you have hat least minSdkVersion 23
3
compileSdkVersion 30
4
defaultConfig {
5
applicationId "com.preventor.example"
6
minSdkVersion 23
7
targetSdkVersion 30
8
versionCode 1
9
versionName "1.0.0"
10
}
11
}
12
13
dependencies {
14
...
15
// 2. Add line here
16
implementation 'com.preventor:preventor_sdk:0.1.213-alpha'
17
}
Copied!
1
repositories {
2
jcenter()
3
maven { url 'https://button.preventor.com/__android'}
4
}
Copied!
You have successfully installed the Preventor SDK!

2. Initialize the SDK

Initialize the SDK. See the coding example below:
Kotlin
Java
1
package com.preventor.example
2
3
// 1. Add import of Preventor SDK
4
import com.preventor.pvtidentityverification.PreventorSDK
5
6
7
class MainActivity : AppCompatActivity() {
8
9
override fun onCreate(savedInstanceState: Bundle?) {
10
super.onCreate(savedInstanceState)
11
setContentView(R.layout.activity_main)
12
13
// 2. Set the context to parameters "activity" and "ViewModelStoreOwner"
14
val preventorSDK = PreventorSDK(this, this)
15
}
16
}
Copied!
1
package com.preventor.example;
2
3
// 1. Add import of Preventor SDK
4
import com.preventor.pvtidentityverification.PreventorSDK;
5
6
7
public class MainActivity extends AppCompatActivity {
8
9
@Override
10
protected void onCreate(Bundle savedInstanceState) {
11
super.onCreate(savedInstanceState);
12
setContentView(R.layout.activity_main);
13
14
// 2. Set the context to parameters "activity" and "ViewModelStoreOwner"
15
PreventorSDK preventorSDK = new PreventorSDK(this,this);
16
}
17
}
Copied!
You have successfully initialize the Preventor SDK!

3. Prefilling configs

To continue with the integration you need to set the prefill shown below. First you must obtain the config object by calling getConfig() method.
kotlin
Java
1
package com.preventor.example
2
3
import com.preventor.pvtidentityverification.PreventorSDK
4
5
class MainActivity : AppCompatActivity() {
6
7
override fun onCreate(savedInstanceState: Bundle?) {
8
super.onCreate(savedInstanceState)
9
setContentView(R.layout.activity_main)
10
11
val preventorSDK = PreventorSDK(this, this)
12
13
// 1. GET CONFIG OBJECT
14
val config = preventorSDK.getConfig()
15
}
16
}
Copied!
1
package com.preventor.example;
2
3
import com.preventor.pvtidentityverification.PreventorSDK;
4
5
public class MainActivity extends AppCompatActivity {
6
7
@Override
8
protected void onCreate(Bundle savedInstanceState) {
9
super.onCreate(savedInstanceState);
10
setContentView(R.layout.activity_main);
11
12
PreventorSDK preventorSDK = new PreventorSDK(this,this);
13
14
// 1. GET CONFIG OBJECT
15
Config config = preventorSDK.getConfig();
16
}
17
}
Copied!

Prefill Flowtype

The flow type defines the biometric process so you must select a flow type.
Kotlin
Java
1
package com.preventor.example
2
3
import com.preventor.pvtidentityverification.PreventorSDK
4
5
class MainActivity : AppCompatActivity() {
6
7
override fun onCreate(savedInstanceState: Bundle?) {
8
super.onCreate(savedInstanceState)
9
setContentView(R.layout.activity_main)
10
11
preventorSDK = PreventorSDK(this, this)
12
13
14
val config = preventorSDK.getConfig()
15
16
// 1. SET THE FLOW TYPE
17
config.flowType = "YOUR_FLOW_ID"
18
}
19
}
Copied!
1
package com.preventor.example;
2
3
import com.preventor.pvtidentityverification.PreventorSDK;
4
5
public class MainActivity extends AppCompatActivity {
6
7
@Override
8
protected void onCreate(Bundle savedInstanceState) {
9
super.onCreate(savedInstanceState);
10
setContentView(R.layout.activity_main);
11
12
PreventorSDK preventorSDK = new PreventorSDK(this,this);
13
14
15
Config config = preventorSDK.getConfig();
16
17
// 1. SET THE FLOW TYPE
18
config.setFlowType("YOUR_FLOW_ID");
19
}
20
}
Copied!
You must assign the flow type code. If it is blank, it will take the flow type by default.

Prefill Credentials

You must set all credentials values ​​to correctly consume our services.
Kotlin
Java
1
package com.preventor.example
2
3
import com.preventor.pvtidentityverification.PreventorSDK
4
5
class MainActivity : AppCompatActivity() {
6
7
override fun onCreate(savedInstanceState: Bundle?) {
8
super.onCreate(savedInstanceState)
9
setContentView(R.layout.activity_main)
10
11
preventorSDK = PreventorSDK(this, this)
12
13
14
val config = preventorSDK.getConfig()
15
16
17
config.flowType = "YOUR_FLOW_ID"
18
19
// 2. SET THE CREDENTIALS
20
config.credentials.apiKey = "YOUR_API_KEY"
21
config.credentials.clientSecret = "YOUR_CLIENT_SECRET"
22
config.credentials.tenant = "YOUR_TENANT"
23
config.credentials.banknu = "YOUR_BANKNU"
24
config.credentials.env = "YOUR_ENV"
25
}
26
}
Copied!
1
package com.preventor.example;
2
3
import com.preventor.pvtidentityverification.PreventorSDK;
4
5
public class MainActivity extends AppCompatActivity {
6
7
@Override
8
protected void onCreate(Bundle savedInstanceState) {
9
super.onCreate(savedInstanceState);
10
setContentView(R.layout.activity_main);
11
12
PreventorSDK preventorSDK = new PreventorSDK(this,this);
13
14
15
Config config = preventorSDK.getConfig();
16
17
18
config.setFlowType("YOUR_FLOW_ID");
19
20
// 2. SET THE CREDENTIALS
21
config.getCredentials().setApiKey("YOUR_API_KEY");
22
config.getCredentials().setClientSecret("YOUR_CLIENT_SECRET");
23
config.getCredentials().setTenant("YOUR_TENANT");
24
config.getCredentials().setBanknu("YOUR_BANKNU");
25
config.getCredentials().setEnv("YOUR_ENV");
26
}
27
}
Copied!
Value
Description
YOUR_API_KEY
your provided apikey.
YOUR_CLIENT_SECRET
your provided clientsecret.
YOUR_TENANT
your provided tenant.
YOUR_BANKNU
your provided banknu.
YOUR_ENV
your provided env.

Prefill Cif Code

The Cifcode is the unique customer profile code.
If the Cifcode is empty, a unique code is assigned.
Kotlin
Java
1
package com.preventor.example
2
3
import com.preventor.pvtidentityverification.PreventorSDK
4
5
class MainActivity : AppCompatActivity() {
6
7
override fun onCreate(savedInstanceState: Bundle?) {
8
super.onCreate(savedInstanceState)
9
setContentView(R.layout.activity_main)
10
11
preventorSDK = PreventorSDK(this, this)
12
13
14
val config = preventorSDK.getConfig()
15
16
17
config.flowType = "YOUR_FLOW_ID"
18
19
config.credentials.apiKey = "YOUR_API_KEY"
20
config.credentials.clientSecret = "YOUR_CLIENT_SECRET"
21
config.credentials.tenant = "YOUR_TENANT"
22
config.credentials.banknu = "YOUR_BANKNU"
23
config.credentials.env = "YOUR_ENV"
24
25
// 3. SET THE CIF CODE
26
config.currentUserInfo.cifCode = "YOUR_CIFCODE"
27
}
28
}
Copied!
1
package com.preventor.example;
2
3
import com.preventor.pvtidentityverification.PreventorSDK;
4
5
public class MainActivity extends AppCompatActivity {
6
7
@Override
8
protected void onCreate(Bundle savedInstanceState) {
9
super.onCreate(savedInstanceState);
10
setContentView(R.layout.activity_main);
11
12
PreventorSDK preventorSDK = new PreventorSDK(this,this);
13
14
15
Config config = preventorSDK.getConfig();
16
17
18
config.setFlowType("YOUR_FLOW_ID");
19
20
config.getCredentials().setApiKey("YOUR_API_KEY");
21
config.getCredentials().setClientSecret("YOUR_CLIENT_SECRET");
22
config.getCredentials().setTenant("YOUR_TENANT");
23
config.getCredentials().setBanknu("YOUR_BANKNU");
24
config.getCredentials().setEnv("YOUR_ENV");
25
26
// 3. SET THE CIF CODE
27
config.getCurrentUserInfo().setCifCode("YOUR_CIFCODE");
28
}
29
}
Copied!

4. Start the Verification

To start a new verification, you first need to create the preventor verification button.

Add Button in your XML

1
<com.preventor.pvtidentityverification.widgets.PreventorButton
2
android:id="@+id/identityVerificationButton"
3
android:layout_width="161dp"
4
android:layout_height="wrap_content"
5
android:layout_centerInParent="true" />
Copied!

Start Verification

To start a verification, prepare the following:
  1. 1.
    Add the reference to verification button.
  2. 2.
    Call initialize() method to start the preventorSDK.
  3. 3.
    Call validateApiKey() method to start the verification.
Kotlin
Java
1
// 1. Add verification button reference.
2
3
val identityVerificationButton = findViewById<PreventorButton>(R.id.identityVerificationButton)
4
5
// 2. Call initialize() method.
6
preventorSDK.initialize()
7
8
// 3. Call validateApiKey() method.
9
identityVerificationButton.setOnClickListener {
10
preventorSDK.validateApiKey()
11
}
Copied!
1
// 1. Add verification button reference.
2
PreventorButton identityVerificationButton = findViewById(R.id.identityVerificationButton);
3
4
// 2. Call initialize() method.
5
preventorSDK.initialize();
6
7
// 3. Call validateApiKey() method.
8
identityVerificationButton.setOnClickListener(new View.OnClickListener() {
9
@Override
10
public void onClick(View v) {
11
preventorSDK.validateApiKey();
12
}
13
});
Copied!

5. Handling Verifications

To find out if a user has completed the verification process, canceled it or there was an error. To do this, you can implement the following delegate / callback methods:
Method
Description
onStart
This callback method is triggered once a user starts the verification flow.
onSubmitted
Method that is being called once verification data is submitted to Preventor.
onFinish
Method that is being called once a user clicks the "Finish" button.
onError
This callback method fires when a user canceled the verification flow, the verification ended with an error, or the user performed an incorrect process. You can use this to find out the reason for the error.
Error codes:
CANCELLED_BY_USER
BIOMETRIC_AUTHENTICATION_FAILED
BAD_STEP_BY_USER
MISSING_PARAMETERS
TIME_OUT
Should look similar to the example below.
Kotlin
Java
1
preventorSDK.callback(object : PreventorSDKListener {
2
override fun onStart() {
3
println("MainActivity onStart");
4
}
5
6
override fun onFinish(ticked: Ticked) {
7
println("MainActivity onFinish");
8
}
9
10
override fun onError(error: String) {
11
println("MainActivity onError: $error");
12
}
13
14
override fun onSubmitted(ticked: Ticked) {
15
println("MainActivity onSubmitted");
16
}
17
18
})
Copied!
1
preventorSDK.callback(new PreventorSDKListener() {
2
@Override
3
public void onStart() {
4
System.out.println("MainActivity onStart");
5
}
6
7
@Override
8
public void onFinish(Ticked ticked) {
9
System.out.println("MainActivity onFinish");
10
}
11
12
@Override
13
public void onError(@NonNull String error) {
14
System.out.println("MainActivity onError: " + error);
15
}
16
17
@Override
18
public void onSubmitted(Ticked ticked) {
19
System.out.println("MainActivity onSubmitted");
20
}
21
});
Copied!

6. Example project

See the example project below: