Android SDK
Getting Started
Latest release: Version 0.6.4
Requirements
Device Requirement
- API level 23 (Android 6.0) or higher
- Internet connection
- Camera
Project Requirement
AndroidX Support
- ShuftiPro SDK requires AndroidX 1.0.0 or later. If you haven't switched to AndroidX in your app yet then follow this guide.
Enable Java 8
- ShuftiPro SDK requires Java 8 language features to be enabled in your project. If it is not already enabled, add this to your app/build.gradle file under the android section:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Resources
- Integration Sample (Java): Java-SDK
- Integration Sample (Kotlin): Kotlin-SDK
Installation
It’s always recommended to use the updated version
Step 1: Go to root-level setting.gradle in your project and add the following:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' } // Add this line
}
}
OR
Go to project
> android
> build.gradle
file and add the following
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' } // add this line
}
}
Step 2: In build.gradle(Module) add the following implementation
implementation 'com.github.shuftipro:ShuftiPro_SDK:0.6.4'
Basic Usage
Make sure you have obtained authorization credentials before proceeding. You can get client id or secret key and generate access token like this.
Authorization
The following code snippet shows how to use the access token in auth object.
Access Token
Make auth object using access token
- Java
- Kotlin
JSONObject AuthKeys = new JSONObject();
try{
AuthKeys.put("auth_type","access_token");
AuthKeys.put("access_token","sp-accessToken");
} catch (JSONException e) {
e.printStackTrace();
}
val AuthKeys = JSONObject().apply {
put("auth_type", "access_token")
put("access_token", "sp-accessToken")
}
Configuration
The Shufti Pro’s mobile SDKs can be configured on the basis of parameters provided in the config object. The details of parameters can be found here.
- Java
- Kotlin
JSONObject Config=new JSONObject();
try{
Config.put("open_webview",false); //pass true for verification through hybrid view
Config.put("asyncRequest",false);
Config.put("captureEnabled",false);
Config.put("dark_mode", false);
Config.put("video_kyc", false);
} catch (JSONException e) {
e.printStackTrace();
}
val Config = JSONObject().apply{
put("open_webview", false) //pass true for verification through hybrid view
put("asyncRequest", false)
put("captureEnabled", false)
put("dark_mode", false)
put("video_kyc", false)
}
Request Object
This object contains the service objects and their settings through which the merchant wants to verify end users. Complete details of service objects and their parameters can be found here.
- Java
- Kotlin
JSONObject requestObject = new JSONObject();
try{
requestObject.put("reference", "12345678");
requestObject.put("country", "US");
requestObject.put("language", "EN");
requestObject.put("email", "");
requestObject.put("callback_url", "");
requestObject.put("verification_mode", "image_only");
requestObject.put("show_results", "1");
//Creating Face object
JSONObject faceObject = new JSONObject();
faceObject.put("proof", "");
requestObject.put("face", faceObject);
//Creating Document object
JSONObject documentObject = new JSONObject();
ArrayList<String> doc_supported_types = new ArrayList<String>();
doc_supported_types.add("passport");
doc_supported_types.add("id_card");
doc_supported_types.add("driving_license");
doc_supported_types.add("credit_or_debit_card");
documentObject.put("proof", "");
documentObject.put("additional_proof", "");
JSONObject docNameObject = new JSONObject();
docNameObject.put("first_name", "Johon");
docNameObject.put("middle_name", "Johsan");
docNameObject.put("last_name", "Livone");
documentObject.put("name", docNameObject);
documentObject.put("dob", "1980-11-12");
documentObject.put("document_number", "19901112");
documentObject.put("expiry_date", "1996-11-12");
documentObject.put("issue_date", "1990-11-12");
documentObject.put("backside_proof_required", "0");
documentObject.put("supported_types",new JSONArray(doc_supported_types));
requestObject.put("document", documentObject);
//Creating Document Two Object is exactly same as document object.
// Add document two to request object like
...
requestObject.put("document_two", documentTwoObject);
//Creating Address object
JSONObject addressObject = new JSONObject();
ArrayList<String> address_supported_types = new ArrayList<String>();
address_supported_types.add("id_card");
address_supported_types.add("passport");
address_supported_types.add("bank_statement");
JSONObject addressNameObject = new JSONObject();
addressNameObject.put("first_name", "Johon");
addressNameObject.put("middle_name", "Johsan");
addressNameObject.put("last_name", "Livone");
addressObject.put("name", addressNameObject);
addressObject.put("proof", "");
addressObject.put("full_address", "ST#2, 937-B, los angles.");
addressObject.put("supported_types",new JSONArray(address_supported_types));
requestObject.put("address", addressObject);
//Creating consent object
JSONObject consentObject = new JSONObject();
ArrayList<String> consent_supported_types = new ArrayList<String>();
consent_supported_types.add("handwritten");
consent_supported_types.add("printed");
consentObject.put("proof", "");
consentObject.put("text", "This is my consent. ");
consentObject.put("supported_types",new JSONArray(consent_supported_types));
requestObject.put("consent", consentObject);
//Creating phone object
requestObject.put("phone", "");
//Creating BGC object
requestObject.put("background_checks", "");
} catch (JSONException e) {
e.printStackTrace();
}
val requestObject = JSONObject().apply {
put("reference", "12345678")
put("country", "US")
put("language", "EN")
put("email", "")
put("callback_url", "")
put("verification_mode", "image_only")
put("show_results", "1")
}
//Creating Face object
val faceObject = JSONObject()
faceObject.put("proof", "")
requestObject.put("face", faceObject)
//Creating Document object
val documentObject = JSONObject().apply {
put("supported_types", JSONArray().apply {
put("id_card")
put("passport")
put("driving_license")
put("credit_or_debit_card")
})
put("proof", "")
put("additional_proof", "")
put("name", JSONObject().apply {
put("first_name", "Johon")
put("middle_name", "Johsan")
put("last_name", "Livone")
})
put("dob", "1980-11-12")
put("document_number", "19901112")
put("expiry_date", "1996-11-12")
put("issue_date", "1990-11-12")
put("backside_proof_required", "0")
}
requestObject.put("document", documentObject)
//Creating Document Two Object is exactly same as document object.
// Add document two to request object like
...
requestObject.put("document_two", documentTwoObject)
//Creating Address object
val addressObject = JSONObject().apply {
put("supported_types", JSONArray().apply {
put("id_card")
put("passport")
put("bank_statement")
})
put("name", JSONObject().apply {
put("first_name", "Johon")
put("middle_name", "Johsan")
put("last_name", "Livone")
})
put("proof", "")
put("full_address", "ST#2, 937-B, los angles.")
}
requestObject.put("address", addressObject)
//Creating consent object
val consentObject = JSONObject().apply {
put("supported_types", JSONArray().apply {
put("handwritten")
put("printed")
})
put("proof", "")
put("text", "This is my consent. ")
}
requestObject.put("consent", consentObject)
//Creating phone object
requestObject.put("phone", "")
//Creating BGC object
requestObject.put("background_checks", "")
Initialisation
Shufti Pro’s mobile SDK can be initialised by using the given method and passing auth, config and request object as the parameters.
- Java
- Kotlin
Shuftipro shuftipro = Shuftipro.getInstance();
shuftipro.shuftiproVerification(requestObject, AuthKeys, Config, MainActivity.this,
new ShuftiVerifyListener() {
@Override
public void verificationStatus(HashMap<String, String> responseSet) {
Log.e("Response",responseSet.toString());
}
});
val shuftipro = Shuftipro.getInstance()
shuftipro.shuftiproVerification(requestObject, AuthKeys, Config, this@MainActivity) {
Toast.makeText(this@MainActivity, it.toString(), Toast.LENGTH_SHORT).show()
}
Verification Types
Native Flow
In the native verification flow, the end-user interacts with the native mobile SDK. The native flow of verification tends to be much faster since the whole process depends on the device's processing power. All the proofs are taken against required services and then a request is made to the server
You can enable native flow by passing false
for open_webview
key in Config
object.
- Java
- Kotlin
Config.put("open_webview",false);
Config.put("open_webview",false)
Hybrid Flow
The hybrid verification flow includes mobile verifications on a web view built on HTML 5 that will show the verification process to the end user. End-user provides the information in the online customer onboarding process. In hybrid flow, proofs are uploaded after every service, verification results are shown simultaneously in case of decline, and the user can retry the request.
You can enable hybrid flow by passing true
for open_webview
key in Config
object.
- Java
- Kotlin
Config.put("open_webview",true);
Config.put("open_webview",true)
In both flows, Shufti Pro provides the facility to their customers to tailor the identity verification services according to their needs.
Callbacks
The SDK receive callbacks on termination, whether after the request completion or if the journey is left mid-way. The call backs are received in
- Java
- Kotlin
new ShuftiVerifyListener() {
@Override
public void verificationStatus(HashMap<String, String> responseSet)
{
Log.e("Response",responseSet.toString());
// Handle callback responses here
}
}
shuftipro.shuftiproVerification(requestObject, AuthKeys, Config, this@MainActivity) {
Toast.makeText(this@MainActivity, it.toString(), Toast.LENGTH_SHORT).show()
// Handle callback responses here
}
The complete list of callback events can be found here.
Callback Handling
All the callbacks can be handled inside the client’s calling activity. The responses and callback handling can be seen below.
On SDK Completion
- Java
- Kotlin
if(responseSet.get("event").equalsIgnoreCase("verification.accepted")){
// Verification accepted callback
}
else if(responseSet.get("event").equalsIgnoreCase("verification.declined")){
// Verification declined callback
}
when (responseSet["event"])
{
"verification.accepted" -> Log.i("Response","accepted") // Verification accepted callback
"verification.declined" -> Log.i("Response","declined") // Verification declined callback
}
On SDK Unauthentication
- Java
- Kotlin
if(responseSet.get("event").equalsIgnoreCase("request.unauthorized")){
// Verification unauthorized callback. This event occurs when the auth header or its parameters are invalid.
}
if(it.get("event").equals("request.unauthorized")){
// Verification unauthorized callback. This event occurs when the auth header or its parameters are invalid.
}
On SDK Error
- Java
- Kotlin
if(responseSet.get("event").equalsIgnoreCase("permission.denied")){
// This callback is returned in case the permissions are declined by the end user.
}
else if(responseSet.get("event").equalsIgnoreCase("request.timeout")){
// This callback is returned in case request took too long and is timed out
}
else if(responseSet.get("event").equalsIgnoreCase("verification.cancelled")){
// This callback is returned when verification is cancelled midway by the end user
}
else if(responseSet.get("event").equalsIgnoreCase("request.invalid")){
// This callback is returned if the request parameters are incorrect.
}
else {
// Some error has been occured during the verification process
}
when (responseSet["event"])
{
"permission.denied" -> Log.i("Response","permission denied") // This callback is returned in case the permissions are declined by the end user.
"request.timeout" -> Log.i("Response","timeout") // This callback is returned in case request took too long and is timed out
"verification.cancelled" -> Log.i("Response","cancelled") // This callback is returned when verification is cancelled midway by the end user
"request.invalid" -> Log.i("Response","invalid request") // This callback is returned if the request parameters are incorrect.
else -> Log.i("Response", "error") // Some error has been occured during the verification process
}
Customisation
ShuftiPro supports a set of customisation options that will influence the appearance of the mobile SDK.
Verification flow and UI
The complete verification journey is customisable. To remove the screen from verification flow, you need to provide that parameter to the SDK through request/config object. For instance;
Request Object
"country" : "GB" // providing a value to this parameter will not ask the end user to provide his country
"verification_mode" : "image_only" // "image_only" or "video_only" values will allow you to avoid mode selection at real-time
"allow_online" : "1" // 1 value will ask the user to capture real time proofs(image or video) depending upon verification mode
"allow_offline" : "1" // 1 value will ask the user to upload proofs(image or video) depending upon verification mode
"decline_on_single_step" : "1" // this parameter will work with onsite flow(open_webview : true). This will show continue the journey only if pervious step is successfully verified
"show_feedback_form" : "1" // this parameter will work with onsite flow(open_webview : true). 1 value will ask the user for its feedback at the end of verification
// Service Level Parameters
"supported_types" : [id_card] // providing a single value to this parameter will not ask the user for document type
"show_ocr_form" : "1" // this parameter will work with onsite flow(open_webview : true). 1 value will show the OCR form to the user
Config Object
"asyncRequest": "true" // passing true value to this parameter will not show result screen to the user and will just return the callback on request completion
Colours
The colour of buttons and font can be customised by overriding the values of following variables in the project's color.xml
file.
<color name="light_button_color">#2B6AD8</color>
<color name="light_text_color">#1D2C42</color>
<color name="dark_button_color">#FF7A77</color>
<color name="dark_text_color">#ffffff</color>
<color name="button_text_color">#FFFFFFFF</color>
Personalization
Shufti Pro provides its users the facility to personalize the text of SDK according to their individual requirements. The text of the SDK can be personalize by changing the values of corresponding variables given in this strings.xml file. The user just has to override the values of desired variables in their own project’s strings.xml file.
Dark mode
To apply and use dark theme/mode in SDK, initialise the SDK with provided parameters in the config object.
Config.put("dark_mode", true);
NFC verification
Near Field Communication (NFC) is a set of short-range wireless technologies. NFC allows sharing small payloads of data between an NFC tag and an NFC-supported device. NFC Chips found in modern passports and similar identity documents contain additional encrypted information about the owner. This information is very useful in verifying the originality of a document. NFC technology helps make the verification process simple, quicker and more secure. This also provides the user with contactless and input less verification. ShuftiPro's NFC verification feature detects MRZ from the document to authenticate NFC chips and retrieve data from it, so the authenticity and originality of the provided document could be verified.
Initialisation
Once the main SDK is integrated successfully, NFC SDK can be integrated easily by adding an additional dependency in app level build.gradle
.
dependencies {
...
implementation 'com.github.shuftipro:NFC:2.2.0'
}
Nfc verification is allowed only on e-passports under document, document_two and address service only. The nfc service is not available in hybrid view for now.
NFC dependency needs to be integrated with main SDK.
Changelog
Date | SDK Versions | Changes |
---|---|---|
May 26, 2023 | 0.6.4 |
|
May 24, 2023 | 0.6.3 |
|
May 18, 2023 | 0.6.2 |
|
May 16, 2023 | 0.6.1 |
|
May 15, 2023 | 0.6.0 |
|
May 09, 2023 | 0.5.9 |
|
Apr 22, 2023 | 0.5.4 |
|
Apr 13, 2023 | 0.5.2 |
|
Apr 06, 2023 | 0.5.0 |
|
Apr 05, 2023 | 0.4.9 |
|
Mar 22, 2023 | 0.4.8 |
|
Mar 16, 2023 | 0.4.7 |
|
Mar 15, 2023 | 0.4.6 |
|
Mar 09, 2023 | 0.4.5 |
|
Mar 01, 2023 | 0.4.4 |
|
Feb 28, 2023 | 0.4.3 |
|
Feb 27, 2023 | 0.4.2 |
|
Feb 22, 2023 | 0.4.1 |
|
Feb 17, 2023 | 0.3.9 |
|
Feb 14, 2023 | 0.3.8 |
|
Feb 13, 2023 | 0.3.7 |
|
Feb 10, 2023 | 0.3.6 |
|
Feb 9, 2023 | 0.3.4 |
|
Feb 3, 2023 | 0.3.3 |
|
Feb 1, 2023 | 0.3.2 |
|
Feb 1, 2023 | 0.3.1 |
|
Jan 31, 2023 | 0.2.9 |
|
Jan 30, 2023 | 0.2.8 |
|
Jan 24, 2023 | 0.2.7 |
|
Jan 16, 2023 | 0.2.6 |
|
Jan 3, 2023 | 0.2.5 |
|
Dec 28, 2022 | 0.2.4 |
|
Dec 23, 2022 | 0.2.3 |
|
Dec 17, 2022 | 0.2.2 |
|
Dec 15, 2022 | 0.2.1 |
|