Live demo of agent247 on Digio's docs — click the orange button at the bottom right to start.

Android Gateway SDK

  1. Test app link
  2. Implementation code base Please follow the following test app code for any confusions
  3. Implementation code base for jetpack implementation Please follow the following test app code for jetpack implementation any confusions

How to Integrate?

digio-bom

1. Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
            google()
            mavenCentral()
            maven { url 'https://jitpack.io' }
            maven {
                 url = uri("https://pkgs.dev.azure.com/eMudhraTrustService/b81ae285-cb60-4000-8c39-394db16f2a75/_packaging/eMudhraEsignAAR/maven/v1")
            }

    }
}

plugins {
    id 'com.android.application' version '8.7.1' apply false
    id 'com.android.library' version '8.7.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.9.20' apply false
    id 'androidx.navigation.safeargs' version '2.8.2' apply false

}

2. Add databinding and view binding settings in the app gradle file

plugins {
   id 'com.android.application'
}

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

   // Make sure your project using
       compileSdkVersion = 35
       targetSdkVersion = 35
}

3. Add the dependencies to use the gateway sdk, please ensure to use the digio bom dependency to manage version of all imports

dependencies {
    implementation(platform("com.github.digio-tech:digio-bom:v1.x.x"))     //Master dependency for digio core sdk, version handling all other sdks, Use latest version from above tag
    implementation 'androidx.appcompat:appcompat'
    implementation 'com.google.android.material:material'
    implementation "androidx.navigation:navigation-fragment-ktx"
    implementation "androidx.navigation:navigation-ui-ktx"

    implementation 'com.github.digio-tech:gateway'                          //Sdk to invoke the all flows
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout'         //required by gateway for webview swipe refresh
    implementation 'com.android.volley:volley'                              //dependency for http requests
    implementation 'com.squareup.okhttp3:okhttp'                            //dependency for request response handling
    implementation 'com.squareup.okhttp3:logging-interceptor'               //dependency for logging requests
    implementation("com.google.code.gson:gson")                             //dependency for parsing request responses


    implementation 'com.github.digio-tech:digio_permissions'                //required if any feature needs permissions like kyc needs camera, audio or location permissions
    implementation 'com.google.android.gms:play-services-location'          //required if feature uses geolocation
}

4. Every feature by digio is given as a dependency import, version controlled by bom. Please include dependencies based on feature used. Ensure the bom dependency is added along with gateway dependencies 5. Include Esign biometric fingure print or face signing in project

    implementation 'com.github.digio-tech:protean-esign'                    //required dependency for signing with nsdl esp partner
    implementation 'com.github.digio-tech:cvl_esign'                        //required dependency for signing with cvl esp partner
    implementation 'com.scottyab:rootbeer-lib'                              //required dependency for using nsdl
    implementation 'com.github.digio-tech:esign_biometrics'                 //required dependency for all kinds of signing otp/iris/face/fp based signing, otp dependency not needed if biometric dependency is used
    implementation 'com.github.digio-tech:cvl_rdservice'                    //required dependency for using cvl based biometric signing
    implementation 'org.simpleframework:simple-xml'
    implementation("com.github.bumptech.glide:glide")
     implementation('com.emudhra:esign:1.0.0-SNAPSHOT') {            // required dependency for signing with emudhra esp partner
        changing = true
    }
    implementation("org.bouncycastle:bcprov-jdk16:1.45")
    implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.15.1") {
        exclude group: "xpp3", module: "xpp3"
        exclude group: "org.xmlpull", module: "xmlpull"
        exclude group: "javax.xml.stream", module: "stax-api"
    }

For sandbox testing please use the pre prod apk at this link

6. Include Kyc phone camera sdk implementation in project

    implementation 'com.github.digio-tech:sdk_native_camera'               //required dependency for excluding option for ml camera face auto detect for kyc, use only if face detection precision is not needed
    implementation 'com.github.digio-tech:image_processor'                 //required dependency for file upload like pan, aadhar, and cropping
    implementation 'androidx.exifinterface:exifinterface'                  //internal dependency (mandatory)

7. Include Kyc with ML camera implementations in project

    implementation 'com.github.digio-tech:sdk_ml_camera'                    //required dependency for using ml camera based face auto detect for kyc native camera sdk not needed if ml camera dependency included
    implementation 'com.afollestad.material-dialogs:core'                   //mandatory dependency for material models
    implementation 'com.google.android.gms:play-services-mlkit-face-detection' //mandatory dependency for using ml camera dependency
    implementation "androidx.camera:camera-core"                            //mandatory dependency for using camerax features
    implementation "androidx.camera:camera-camera2"                         //mandatory dependency for using camerax features
    implementation "androidx.camera:camera-lifecycle"                       //mandatory dependency for using camerax features
    implementation "androidx.camera:camera-view"                            //mandatory dependency for using camerax features
    implementation "androidx.camera:camera-video"                           //mandatory dependency for using camerax features
    implementation 'androidx.preference:preference-ktx'                     //mandatory dependency for using storage access
    implementation 'androidx.exifinterface:exifinterface'                   //mandatory dependency for using sdk features

8. Include Signing mandate in project

    implementation 'com.github.digio-tech:esign_mandate'                    //required dependency for using mandate
    implementation 'androidx.core:core-ktx'                                 //android dependencies
    implementation 'androidx.appcompat:appcompat'                           //android dependencies
    implementation 'androidx.activity:activity-ktx'                         //android dependencies
    implementation("androidx.constraintlayout:constraintlayout")           //android constraintlayout

9. Include Offline Kyc in project

    
    implementation 'androidx.activity:activity-ktx'                          //android dependencies  mandatory
    implementation 'androidx.constraintlayout:constraintlayout'              //android dependencies   mandatory
    implementation 'androidx.appcompat:appcompat'                            //android dependencies   mandatory
    implementation 'com.google.android.material:material'                    //android dependencies material
    implementation "androidx.navigation:navigation-fragment-ktx"             //android dependencies fragment navigation
    implementation "androidx.navigation:navigation-ui-ktx"                   //android dependencies navigation
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout'          //swipe refresh functionality for webview
    implementation 'com.google.code.gson:gson'                               // dependencies for handling response request

10. Include UPI in project

    implementation 'com.github.digio-tech:sdk_upi'                          //required dependency for digio upi feature
    implementation("androidx.core:core-ktx")                                //android dependencies  mandatory
    implementation("com.squareup.retrofit2:retrofit")                       //android dependencies  mandatory
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android")      //android dependencies  mandatory
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")         //android dependencies  mandatory
    implementation("androidx.fragment:fragment-ktx")                        //android dependencies  mandatory
    implementation("androidx.lifecycle:lifecycle-livedata-ktx")             //android dependencies  mandatory
    implementation("com.squareup.retrofit2:converter-gson")                // dependencies for handling response request

11. Include Two way video sdk in project

implementation("live.videosdk:rtc-android-sdk") {
    exclude(group = "org.json", module = "json")
}
// For ViewModel's coroutine scope
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx")
implementation ("com.github.bumptech.glide:glide")
implementation("com.github.amitshekhariitbhu.Fast-Android-Networking:android-networking") {
    exclude(group = "com.android.support")
}
implementation ("com.airbnb.android:lottie:6.6.6")
implementation("io.coil-kt:coil:2.6.0")

implementation("com.github.digio-tech:two_way_video")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx")
implementation("com.github.amitshekhariitbhu.Fast-Android-Networking:android-networking")
implementation("com.github.digio-tech:two_way_video")
implementation("com.github.digio-tech:digio_permissions")

Please ensure using the gateway and the digio bom dependency first before using any other feature. When using bom dependency we handle the versions for each module and dependency implementations. In case any dependency is missing for a module, please check logs for import messages. In case you want to override provided dependency version, give the specific version when adding dependency.

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" />
<uses-permission android:name="android.permission.ACCESS_FINE_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 - It can be used but requires clarification when releasing on playstore
Read_phone_numbers
Read_media_videos

Note: All required permission should be define in manifest file as well as take runtime permission. Permissions on Android , optionally required permissions should be asked before starting the workflow.

How to trigger the sdk flow

When triggering from java activity

1. Implement the DigioSuccessFailureInterface in the activity or fragment

public class MainActivity extends AppCompatActivity implements DigioSuccessFailureInterface {
   @Override
    protected void onCreate(Bundle savedInstanceState) {
     }

//this event is triggered on each event, be it failure or success or screen event updates, keep a log to provide inputs
    @Override
    public void onUpdateEvent(@Nullable GatewayEvent event) {
        assert event != null;
        binding.response.setText(event.toString());
        Log.d(TAG, "onUpdateEvent: " + event.toString());
    }

    //called when the process is completed successfully
    @Override
    public void onSuccess(@Nullable DigioSdkResponse sdkResponse) {
        assert sdkResponse != null;
        binding.response.setText(sdkResponse.toString());
        Log.d(TAG, "onSuccess: " + sdkResponse);
    }

    //called when the process is failed due to any reasons. Please check message inside the DigioSdkResponse object to get the reasons and debug accordingly
    @Override
    public void onFailure(@Nullable DigioSdkResponse sdkResponse) {
        assert sdkResponse != null;
        binding.response.setText(sdkResponse.toString());
        Log.d(TAG, "onFailure: " + sdkResponse);
    }
}

2. Add DigioTheme to be used

        DigioTheme theme = new DigioTheme();
        theme.setPrimaryColor(android.R.color.holo_red_dark);
        theme.setPrimaryColorHex("#0261B0");
        theme.setFontFamily("Unbounded");
        theme.setSecondaryColorHex("#141414");
        theme.setFontUrl("https://fonts.googleapis.com/css2?family=Unbounded:wght@200&display=swap");

3. Create a DigioConfig object Use the theme object created above

        DigioConfig digioConfig = new DigioConfig();
        digioConfig.setTheme(theme);
        digioConfig.setFaqButton(android.R.drawable.ic_menu_help);
        digioConfig.setCloseButton(android.R.drawable.ic_menu_close_clear_cancel);
        digioConfig.setLogo("https://www.digio.in/images/digio_blue.png"); // Your company logo url
        digioConfig.setEnvironment(DigioEnvironment.PRODUCTION); // SANDBOX or PRODUCTION
        digioConfig.setServiceMode(DigioServiceMode.OTP); // OTP/FACE/IRIS/FP


        //add the user identifier, request ID and token for the session
        digioConfig.setGToken("GWT2310191738"); // Optional: token id to bypass first factor authentication
        digioConfig.setRequestId("DID2405201027408WRECZKLB57ORQW"); // Mandatory Unique MandateId /Document ID/ RequestId
        digioConfig.setUserIdentifier("a@gmail.com"); // Mandatory identifier email/mobileNumber

4. Sdk must be initialsed in the oncreate of the activity or fragment. Call the start only after init is called

public class MainActivity extends AppCompatActivity implements DigioSuccessFailureInterface {
    Digio digio = new Digio();
    DigioConfig digioConfig = new DigioConfig();
    DigioTheme theme = new DigioTheme();


    @Override
    protected void onCreate(Bundle savedInstanceState) {
      digio.initSession(MainActivity.this, this);      //ensure init is called first before start
      initDigioConfig()
    }

    private void setTheme() {
        theme.setPrimaryColor(android.R.color.holo_red_dark);
        theme.setPrimaryColorHex("#0261B0");
        theme.setFontFamily("Unbounded");
        theme.setSecondaryColorHex("#141414");
        theme.setFontUrl("https://fonts.googleapis.com/css2?family=Unbounded:wght@200&display=swap");
    }

    private void initDigioConfig() {
        setTheme()
        digioConfig.setTheme(theme);
        digioConfig.setFaqButton(android.R.drawable.ic_menu_help);
        digioConfig.setCloseButton(android.R.drawable.ic_menu_close_clear_cancel);
        digioConfig.setLogo("https://www.digio.in/images/digio_blue.png"); // Your company logo url
        digioConfig.setEnvironment(DigioEnvironment.PRODUCTION); // SANDBOX or PRODUCTION
        digioConfig.setServiceMode(DigioServiceMode.FACE); // OTP/FACE/IRIS/FP

        //add the user identifier, request ID and token for the session
        digioConfig.setGToken("GWT2310191738");
        digioConfig.setRequestId("DID2405201027408WRECZKLB57ORQW");
        digioConfig.setUserIdentifier("a@gmail.com");

        //This can be called even on buttonClicks
        binding.startProcessButton.setOnClickListener(v -> {
           startSession()
        });
        startSession()
    }

    private void startSession() {
        try {
            digio.startSession(                             //ensure init is called before calling start
                    digioConfig,
                    this
            );
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

5. ForFor clients willing to use UPI and OKYC sdk should pass the DigioServiceMode explicitly. clients willing to use UPI and OKYC sdk should pass the DigioServiceMode explicitly.

    private void initDigioConfig() {
        setTheme()
        ...
        digioConfig.setEnvironment(DigioEnvironment.PRODUCTION); // SANDBOX or PRODUCTION
        digioConfig.setServiceMode(DigioServiceMode.UPI);     //Explicitly pass UPI/OKYC
        ....
    }

6. Note - Please check logs in the onUpdate event of the DigioSuccessFailureListener for any kind of issues or events 7. Please follow the following test app for any confusions 8. Progaurd rules needed for release builds

-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
-keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
}
-keepattributes JavascriptInterface
-keepattributes *Annotation*
-keepattributes Signature
-optimizations !method/inlining/*
-keeppackagenames
-keepnames class androidx.navigation.fragment.NavHostFragment
-keep class * extends androidx.fragment.app.Fragment{}
-keepnames class * extends android.os.Parcelable
-keepnames class * extends java.io.Serializable
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}
-dontwarn androidx.databinding.**
-keep class androidx.databinding.** { *; }
-keepclassmembers class * extends androidx.databinding.** { *; }
-dontwarn org.json.**
-keep class org.json** { *; }
-keep public class org.simpleframework.**{ *; }
-keep class org.simpleframework.xml.**{ *; }
-keep class org.simpleframework.xml.core.**{ *; }
-keep class org.simpleframework.xml.util.**{ *; }
-dontwarn com.google.android.gms.**
-keep class com.google.android.gms.** { *; }
-keep class com.google.android.material.** { *; }
-dontwarn org.simpleframework.**
-keepattributes ElementList, Root
-keepclassmembers class * {
    @org.simpleframework.xml.* *;
}
-keep class org.spongycastle.** { *; }
-keep class com.ecs.rdlibrary.request.** { *; }
-keep class com.ecs.rdlibrary.response.** { *; }
-keep class com.ecs.rdlibrary.utils.** { *; }
-keep class com.ecs.rdlibrary.ECSBioCaptureActivity { *; }
-keep class org.simpleframework.xml.** { *; }
-keepattributes Exceptions, InnerClasses
-keep class com.google.android.gms.location.LocationSettingsRequest$Builder { *; }
-keepnames class ** { *; }
-keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
}
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
-keepattributes AnnotationDefault
-keepclassmembers,allowshrinking,allowobfuscation interface * {
    @retrofit2.http.* <methods>;
}
-dontwarn javax.annotation.**
-dontwarn kotlin.Unit
-dontwarn retrofit2.KotlinExtensions
-dontwarn retrofit2.KotlinExtensions$*
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface * extends <1>
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
-if interface * { @retrofit2.http.* public *** *(...); }
-keep,allowoptimization,allowshrinking,allowobfuscation class <3>
-keep,allowobfuscation,allowshrinking class retrofit2.Response
-adaptresourcefilenames okhttp3/internal/publicsuffix/PublicSuffixDatabase.gz
-dontwarn org.codehaus.mojo.animal_sniffer.*
-dontwarn okhttp3.internal.platform.**
-dontwarn org.conscrypt.**
-dontwarn org.bouncycastle.**
-dontwarn org.openjsse.**
-keep class * extends androidx.databinding.DataBinderMapper
-keep class javax.xml.bind.annotation.** { *; }
-dontwarn javax.xml.bind.annotation.**
-keep class com.ecs.cdslxsds.ESignProcessorResponse { *; }
-dontwarn org.xmlpull.v1.XmlPullParser
-dontwarn android.content.res.XmlResourceParser


#emudhra
-keep class com.emudhra.** { *; }
-keep interface com.emudhra.** { *; }
-keepclassmembers class com.emudhra.** {
    native <methods>;
}
-dontwarn com.emudhra.**

# Jackson dataformat XML (used by emudhra at runtime via XmlMapper)
-keep class com.fasterxml.jackson.** { *; }
-keepnames class com.fasterxml.jackson.** { *; }
-dontwarn com.fasterxml.jackson.**

# Woodstox - StAX implementation backing jackson-dataformat-xml.
# FactoryFinder uses Class.forName via META-INF/services lookup; the impl
# classes must not be obfuscated or shrunk away.
-keep class com.ctc.wstx.** { *; }
-keep class org.codehaus.stax2.** { *; }
-dontwarn com.ctc.wstx.**
-dontwarn org.codehaus.stax2.**

# StAX API surfaces referenced via reflection
-keep class javax.xml.stream.** { *; }
-dontwarn javax.xml.stream.**
-keep class * implements javax.xml.stream.XMLInputFactory
-keep class * implements javax.xml.stream.XMLOutputFactory
-keep class * implements javax.xml.stream.XMLEventFactory

-keepattributes Signature, *Annotation*, EnclosingMethod, InnerClasses

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 logcat for crash logs.

Known issues and integration problems faced can be checked in the following link

DigioConfig Params

ParamsDigioServiceModeDefault/Mandatory
DigioEnvironmentSANDBOX, PRODUCTIONDefault : PRODUCTION
DigioServiceModeOTP, FP, IRIS, FACE, OKYC, UPI, KYC, MANDATEOTP : (Default) Aadhaar OTP authentication based eSign
FP : Fingerprint authentication based Aadhaar eSign (Biometric)
IRIS : Iris authentication based Aadhaar eSign
FACE : Face authentication based Aadhaar eSign
OKYC : Use when integrating OKYC flows
UPI : Use when integrating UPI flows
KYC : Use when integrating KYC workflows
Mandate : Use when integrating Mandate flows
Logologo url max 100 charDigio logo will be used if not passed
ThemePrimary ColorPrimary color for eSign/eMandate journey

Start Params

ParamsTypeReason/Mandatory
DocumentIdMandatoryA document id starts with DID** or ENA** or KID**. It can be any other id's as generated
IdentifierMandatoryIdentifier can be email or phone number.
TokenIdOptionalTokenId is used to avoid first factor authentication. (GWT**)

Sample Response

documentIdDID22040413040490937VNTC6LAP8KWDString format (Request ID Passed by parent app)
messageSigning SuccessSigning Failure
Failure = Digio sdk crash
Webpage could not be loaded = web page not loaded due to internet connection issue even after 3 retries.
code1001
(App should only depend upon the code not on message to check failure or success)
DigioConstants.RESPONSE_CODE_SUCCESS = 1001
RESPONSE_CODE_CANCEL = -1000
RESPONSE_CODE_FAIL = 1002
RESPONSE_CODE_WEB_VIEW_CRASH = 1003
RESPONSE_CODE_SDK_CRASH = 1004
screendocument_preview
npciTxnIdString
stacktraceIn case of digio sdk crashes, the crash log

Gateway Events :

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

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

Change Logs

Refer to the latest change logs and updates here.

  • Version 5.0.0 :
    • Integrated all digio sdks into a single sdk. Handling versions of all sdk using BOM dependency management.
  • Version 4.0.8 :
    • Added FACE authentication to eSign
    • Using protean eSign SDK for biometric and face based authentication
    • Removed firebase crashlytics
  • 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.8 => 5.0.0 :
  id 'com.android.application' version '8.7.1' apply false
  id 'com.android.library' version '8.7.1' apply false
  id 'org.jetbrains.kotlin.android' version '1.9.20' apply false
  id 'androidx.navigation.safeargs' version '2.8.2' apply false
  dependencies {
      implementation(platform("com.github.digio-tech:digio-bom:v1.x.x"))
  }
  * using BOM dependency management
  • 4.0.6 => 4.0.8
    • Remove firebase crashlytics dependencies and gradle plugin if not required by app.
    • Add following dependencies implementation 'com.github.digio-tech:protean-esign:v3.12'
    • Add following to pro-guard rules
 -dontwarn org.json.**
 -keep class org.json** { *; }
  • 4.0.3 => 4.0.6
    • implemented onGatewayEvent on DigioResponseListener
    • add following dependencies
    • add implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' to build.gradle

Was this page helpful?