Skip to content

digioAbhi/sdk_native_camera

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Digio Kyc Workflow SDK

How to Integrate?

  1. Add it in your root build.gradle at the end of repositories:
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

plugins {
   id 'com.android.application' version '7.4.2' apply false
   id 'com.android.library' version '7.4.2' apply false
   id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
   id 'androidx.navigation.safeargs' version '2.4.2' apply false
   id 'com.google.gms.google-services' version '4.3.10' apply false
}

  1. Add the dependency and view/data Binding build config:
plugins {
   id 'com.android.application'
}

android {
   ...
   buildFeatures {
       viewBinding true
       dataBinding true
   }
}

dependencies {
    implementation 'com.github.digio-tech:gateway:v4.0.10'
    implementation 'com.github.digio-tech:gateway_kyc:v4.0.13'
    
    // Other dependencies
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.9.0'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
    implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
    // Added in version 4.0.6
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

    Following dependency is also not required if org.jetbrains.kotlin.android plugin version is 1.8.*
    implementation 'androidx.core:core-ktx:1.10.0'
    
    implementation 'androidx.exifinterface:exifinterface:1.3.6'
    implementation 'androidx.preference:preference:1.2.0'

    implementation "androidx.camera:camera-camera2:1.2.2"
    implementation "androidx.camera:camera-lifecycle:1.2.2"
    implementation "androidx.camera:camera-view:1.2.2"

    implementation "androidx.navigation:navigation-fragment-ktx:2.5.3"
    implementation "androidx.navigation:navigation-ui-ktx:2.5.3"

    // Use this dependency to use dynamically downloaded model in Google Play Service
    implementation 'com.google.android.gms:play-services-mlkit-face-detection:17.1.0'
    implementation 'com.google.android.gms:play-services-location:21.0.1'
}
  1. Permissions : Add required permissions in manifest file and run time. Note - This is the common SDK for various KYC flows
<!--RECORD_AUDIO and MODIFY_AUDIO_SETTINGS Permission required for Video KYC -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

/** Required for geo tagging */
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />


/** Required for ID card analysis, selfie  and face match**/
<uses-permission android:name="android.permission.CAMERA" />

<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-feature android:name="android.hardware.camera.autofocus"   android:required="false" />

A fintech android app can't access following permission

  • Read_external_storage
  • Read_media_images
  • Read_contacts
  • Access_fine_location
  • Read_phone_numbers
  • Read_media_videos

Note: All required permission should be define in manifest file as well as take runtime permission, digio kyc sdk also handles the runtime permission starting from sdk version 4.0.1 please go through how to request permission Permissions on Android , optionally required permissions should be asked before starting the workflow.

  1. After updating dependencies click File => Sync Project with Gradle Files

Digio SDK supports android version 5.0 and above (SDK level 21 above)

Note - For hybrid applications, you need to create a channel/bridge/plugin to communicate with the native SDK.

Steps to Invoke Kyc workflow

  1. Configure Digio instances : should be called on activity/fragment onCreate
DigioWorkflowSession digioWorkflowSession = new DigioWorkflowSession();

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    DigioConfig digioConfig = new DigioConfig();
    DigioTheme theme = new DigioTheme();
    theme.setPrimaryColor(android.R.color.holo_red_dark);
    theme.setFontFamily("Unbounded");
    theme.setFontUrl("https://fonts.googleapis.com/css2?family=Unbounded:wght@200&display=swap");
    digioConfig.setTheme(theme);
    digioConfig.setLogo("https://www.digio.in/images/digio_blue.png"); // Your company logo url
    digioConfig.setEnvironment(DigioEnvironment.SANDBOX); // SANDBOX or PRODUCTION
    digioConfig.setServiceMode(DigioServiceMode.OTP);  // FP/OTP/IRIS
    try {
        digioWorkflowSession.init(this, digioConfig);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
  1. DigioResponseListener and import onDigioSuccess, onDigioFailure override function in your activity/fragment. Below are function signatures
@Override
public void onWorkflowSuccess(@NonNull WorkflowResponse workflowResponse) {
    Log.d("Response", "onDigioKycSuccess--> documentId " + workflowResponse.getDocumentId() + " message " + workflowResponse.getMessage());
}

@Override
public void onWorkflowFailure(@NonNull WorkflowResponse workflowResponse) {
    Log.d("Response", "onDigioKycFailure--> documentId " + workflowResponse.getDocumentId() + " message " + workflowResponse.getMessage());
    if (workflowResponse.getErrorCode() != null && workflowResponse.getErrorCode() == DigioErrorCode.DIGIO_PERMISSIONS_REQUIRED.getErrorCode()) {
        String[] requiredPermissions = workflowResponse.getPermissions();
        if (requiredPermissions != null && requiredPermissions.length > 0) {
            this.requiredPermissions = requiredPermissions;
            // Digio provides list of permission which is required to complete the workflow.
            // take necessary action whether close the process or ask permission and restart workflow session.
            // explain user why permission is required and how to enable permission.
           
        }
    }
}

@Override
public void onGatewayEvent(@NonNull GatewayEvent gatewayEvent) {
    System.out.println("gatewayEvent = " + gatewayEvent);
}
  1. Starting the sign flow
try {
    // First args : Document Id starting with KID
    // Second args : Identifier (Email/Mobile)
    // Third args (optional) : GWT token to skip the first factor authentication
    digioWorkflowSession.start("KID***", "**Email/Mobile**", "GWT***");
} catch (Exception e) {
    e.printStackTrace();
}
  1. Proguard : No action is required for latest stable android studio, proguard-rules are already added to the sdk.

It is required to test the release build for possible proguard exceptions before prod releases.

App crash after starting digio flow :

  • Make sure init is called before start and all the parameter values are proper as the documentation.
  • There is no missing dependency as described above.

Check out our demo App implementation

Demo App Apks : PRODUCTION , SANDBOX

Environment

DigioEnvironment

SANDBOX

PRODUCTION

Mandatory

Parameter and uses

Params Param Type Reason
TokenId Optional TokenId is optional to avoid first factor authentication
requestId Mandatory You can get it from kyc request APIs
Identifier Mandatory Identifier can be email or phone number. Which has passed to the kyc request APIs.

Sample Success Response

requestId KID211022123015947IKIP3BM1R1RE1Y String format (Request ID Passed by parent app)
message Success String format

Sample Failure Response

requestId KID211022123015947IKIP3BM1R1RE1Y String format (Request ID Passed by parent app)
message

{

“screen":"starting_digio",

“code”:-1000,

"error_code":-1000,

"message":"User cancelled before completion."

“permissions”: [],

“stack_trace” : “”

}

JSON format

Possible error codes and reason :

Code Reason
-1000 User Cancellation before KYC is complete.
1002

KYC Failed

Webview Loading Errors

1003 System Webview crash due to low memory or version compatibility issue (Added in V4.0.6)
1004 Digio SDK crashes due to unknown reason. Check stactTrace param of WorkflowResponse, (Added in V4.0.6)
1008

Required permission not provided

(permissions : Array

param in WorkflowResponse permissions which required and user denied)

Gateway Events :

Refer Gateway document for all posible events and error data : Gateway Event Doc

DigioEvent
documentId: string;
txnId: string;
entity: string;
identifier: string;
event: string;
payload:
type: 'error' | 'info';
data?: HashMap<String,Any>;
error?:
code: string;
message: string;

Webview Error Codes and messages. The following webview errors are already handled by digio SDK, The name,description and message will be displayed during sdk journey if any internet connectivity issue happens.

name error code description from webview client error code messages (manually mapped, error_code may differ)
ERROR_UNKNOWN Generic error -1

net::ERR_FAILED

net::ERR_CACHE_MISS

ERROR_HOST_LOOKUP Server or proxy hostname lookup failed -2

net::ERR_INTERNET_DISCONNECTED

net::ERR_NAME_RESOLUTION_FAILED

net::ERR_NAME_NOT_RESOLVED

ERROR_UNSUPPORTED_AUTH_SCHEME Unsupported authentication scheme (not basic or digest) -3 net::ERR_ACCESS_DENIED
ERROR_AUTHENTICATION User authentication failed on server -4
ERROR_PROXY_AUTHENTICATION User authentication failed on proxy -5
ERROR_CONNECT Failed to connect to the server -6

net::ERR_CONNECTION_FAILED

net::ERR_ABORTED

net::ERR_CONNECTION_ABORTED

net::ERR_CONNECTION_CLOSED

ERROR_IO Failed to read or write to the server -7

net::ERR_INVALID_RESPONSE

net::ERR_EMPTY_RESPONSE

net::ERR_CONTENT_DECODING_FAILED

net::ERR_CONTENT_LENGTH_MISMATCH

ERROR_TIMEOUT Connection timed out -8 net::ERR_CONNECTION_TIMED_OUT
ERROR_REDIRECT_LOOP Too many redirects -9 net::ERR_TOO_MANY_REDIRECTS
ERROR_UNSUPPORTED_SCHEME Unsupported URI scheme -10 net::ERR_UNKNOWN_URL_SCHEME
ERROR_FAILED_SSL_HANDSHAKE Failed to perform SSL handshake -11

net::ERR_SSL_PROTOCOL_ERROR

net::ERR_CERT_DATE_INVALID

net::ERR_CERT_AUTHORITY_INVALID

net::ERR_BAD_SSL_CLIENT_AUTH_CERT

net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED

ERROR_BAD_URL Malformed URL -12 net::ERR_INVALID_URL
ERROR_FILE Generic file error -13 net::ERR_FILE_TOO_BIG
ERROR_FILE_NOT_FOUND File not found -14 net::ERR_FILE_NOT_FOUND
ERROR_TOO_MANY_REQUESTS Too many requests during this load -15
ERROR_UNSAFE_RESOURCE Resource load was canceled by Safe Browsing -16 net::ERR_INSUFFICIENT_RESOURCES
net::ERR_INVALID_HANDLE
net::ERR_CONTENT_DECODING_FAILED
net::ERR_CONTENT_LENGTH_MISMATCH

Change Logs

  • Version 4.0.11 => 4.0.13

    • UIDAI OKYC changes
  • Version 4.0.11

    • Fixed camera target resolution issue when used with flutter.
  • Version 4.0.9 :

    • Removed firebase crashlytics
    • For reverse penny drop added upi apps intent flow.
  • Version 4.0.8 :

    • Removed firebase crashlytics
    • For reverse penny drop added upi apps intent flow.
  • Version 4.0.6 :

    • Introduced webview connection error handling with in digio sdk.
    • Added internet connection observability, if internet connection get disconnected message will be displayed with in digio sdk.
    • Digio activity will run in portrait mode only and will not re-create on any system configuration changes
    • Digio Activity will not run in separate process, there is no requirement of any handling in Application class.
    • Introduced Gateway events

Migration Guide

  • 4.0.6 => 4.0.9

    • Remove firebase crashlytics dependencies and gradle plugin if not required by app or other sdk's.
  • 4.0.3 => 4.0.6

    • implemented onGatewayEvent on DigioWorkflowResponseListener
    • add following dependencies
    • add implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' to build.gradle

Note: Digio reserves the right to modify this API document from time-to-time. If you are a business using this API, you will be notified well in advance, prior to any change is made

© Copyright 2016-23 | www.digio.in | For Limited Circulation

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published