Skip to main content

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

Installation

Tip

It’s always recommended to use the updated version

Step 1: Go to root-level setting.gradle in your project and add the following:

setting.gradle
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

app/build.gradle
implementation 'com.github.shuftipro:ShuftiPro_SDK:0.6.4'

Basic Usage

Note

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
JSONObject AuthKeys = new JSONObject();

try{
AuthKeys.put("auth_type","access_token");
AuthKeys.put("access_token","sp-accessToken");
} catch (JSONException e) {
e.printStackTrace();
}

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.

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();
}

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.

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();
}

Initialisation

Shufti Pro’s mobile SDK can be initialised by using the given method and passing auth, config and request object as the parameters.

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());

}
});

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.

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.

Config.put("open_webview",true);
info

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

 new ShuftiVerifyListener() {
@Override
public void verificationStatus(HashMap<String, String> responseSet)
{
Log.e("Response",responseSet.toString());
// 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

if(responseSet.get("event").equalsIgnoreCase("verification.accepted")){
// Verification accepted callback
}
else if(responseSet.get("event").equalsIgnoreCase("verification.declined")){
// Verification declined callback
}

On SDK Unauthentication

if(responseSet.get("event").equalsIgnoreCase("request.unauthorized")){
// Verification unauthorized callback. This event occurs when the auth header or its parameters are invalid.
}

On SDK Error

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
}

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.

app/build.gradle
dependencies {
...
implementation 'com.github.shuftipro:NFC:2.2.0'
}
info

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.

Note

NFC dependency needs to be integrated with main SDK.

Changelog

DateSDK VersionsChanges
May 26, 20230.6.4
  • Fix Previous Image concern.
May 24, 20230.6.3
  • Fix PDF in upload case
May 18, 20230.6.2
  • Improve logging and handle manual review key
May 16, 20230.6.1
  • Fixed logging issues in SDK
May 15, 20230.6.0
  • Added encryption and improved the logging system of the SDK.
May 09, 20230.5.9
  • Improve the security of SDK
Apr 22, 20230.5.4
  • Uploaded blank PDF issue fixed
Apr 13, 20230.5.2
  • Text allignment on upload screen fixed
Apr 06, 20230.5.0
  • Fix the stepper issue in SDK
Apr 05, 20230.4.9
  • Add flip animation and improve request encryption
Mar 22, 20230.4.8
  • Updated UI and proguard rules
Mar 16, 20230.4.7
  • Countries list is updated
Mar 15, 20230.4.6
  • Exception handled on autocapture and UI updated for custom supported types
Mar 09, 20230.4.5
  • Strings.xml file is updated to avoid accidental asset overriding
Mar 01, 20230.4.4
  • Remove the Test-Ids feature and minor bug fixes.
Feb 28, 20230.4.3
  • Improve assets management and reduce the size of SDK
Feb 27, 20230.4.2
  • Improve the NFC functionality
Feb 22, 20230.4.1
  • Add android 13 permission support in onsite flow
Feb 17, 20230.3.9
  • SDK calling activity configuration issue fixed
    • On closing SDK the user's calling activity's configurations are restored
Feb 14, 20230.3.8
  • Memory leaks handled
    • On socket connection issue, the memory leak was handled
Feb 13, 20230.3.7
  • Cloudfare timeout response handled
Feb 10, 20230.3.6
  • Updated gradle version in SDK
    • Gradle version is updated from 6.5 to 7.5
Feb 9, 20230.3.4
  • Null object checks handled
    • On instance lost the sdk null objects are handled properly
Feb 3, 20230.3.3
  • "duplicate_face_match" key added
    • This checks if the face matches any pervious verification.
Feb 1, 20230.3.2
  • MRZ scanning is improved
    • MRZ is now being extracted from full captured image
Feb 1, 20230.3.1
  • Fix the SDK screen size layout issue when the user device size is maximum.
Jan 31, 20230.2.9
  • Improve the image quality of document service.
  • In document service show & submit full document image.
Jan 30, 20230.2.8
  • Improve the security of shuftipro assets replacement
Jan 24, 20230.2.7
  • Added video KYC service inside SDK in which users can verify identity through video calls with the shuftipro agent.
Jan 16, 20230.2.6
  • Tap to focus feature is added to camera
  • Image quality while capturing proofs, is increased
Jan 3, 20230.2.5
  • Improved internet connectivity checks, SDK will now check for limited internet connections
  • Onsite SDK crash log due to unhandled exception is resolved.
Dec 28, 20220.2.4
  • Logging mechanism for failed nfc tries added
  • UI for nfc verification was improved
    • Animated instruction(gif) for NFC was improved
    • Data representation was improved
Dec 23, 20220.2.3
  • Option to switch between visual and textual instructions is added.
Dec 17, 20220.2.2
  • Support for android 13 added.
    • Android 13 do not require storage permission. So, the need of storage permission was removed for android 13.
Dec 15, 20220.2.1
  • Improved instructions for face verification
    • More accurate instructions were added in image form.