diff --git a/README.md b/README.md index 0e0334c..17bf458 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ Documentation of Digio Gateway Integration and their usage Instantiate the Digio instance with `environment` & other options ```tsx -import { Digio, DigioConfig, DigioResponse } from '@digiotech/react-native'; +import { Digio, DigioConfig, DigioResponse, ServiceMode } from '@digiotech/react-native'; -const config: DigioConfig = { environment: Environment.PRODUCTION }; +const config: DigioConfig = { environment: Environment.PRODUCTION, serviceMode: ServiceMode.OTP }; const digio = new Digio(config); const documentId = ""; const identifier = ""; @@ -36,7 +36,7 @@ For a complete list of events and the payload associated with it, refer [here](h ```tsx import { useEffect } from 'react'; -import { Digio, DigioConfig, GatewayEvent } from '@digiotech/react-native'; +import { Digio, DigioConfig, GatewayEvent, ServiceMode } from '@digiotech/react-native'; function YourComponent() { useEffect(() => { @@ -57,7 +57,7 @@ function YourComponent() { ```tsx import { useEffect } from 'react'; -import { Digio, DigioConfig, GatewayEvent } from '@digiotech/react-native'; +import { Digio, DigioConfig, GatewayEvent, ServiceMode } from '@digiotech/react-native'; function YourComponent() { useEffect(() => { @@ -73,7 +73,7 @@ function YourComponent() { }, []); const triggerDigioGateway = async () => { - const config: DigioConfig = { environment: Environment.PRODUCTION }; + const config: DigioConfig = { environment: Environment.PRODUCTION, serviceMode: ServiceMode.OTP }; const digio = new Digio(config); const documentId = ""; const identifier = ""; @@ -85,18 +85,17 @@ function YourComponent() { ``` ## Android -#### Note: Incase you are using camera feature and facing black screen on camera then follow below steps -- Add digioKycworkflow.aar file inside your react project under android/app/libs folder. [Download digio_kyc_workflow-4.0.15.aar](https://drive.google.com/file/d/1nHeZhDBPavLxwJp0VgNrMiEZpXswENgz/view?usp=sharing) - - - Add below in your project under build.gradle (module:app)file inside dependencies ```tsx -implementation fileTree(dir: 'libs', include: ['*.aar']) -// Required for KYC/work_flow /video/2way video -implementation 'com.github.digio-tech:gateway_kyc:v4.0.20' // Required for esign/mandate sign implementation 'com.github.digio-tech:protean-esign:v3.2' +// under android {} of build.gradle(module:app) + buildFeatures { + viewBinding true + dataBinding true + } + ``` ## SDK Reference @@ -105,11 +104,12 @@ implementation 'com.github.digio-tech:protean-esign:v3.2' **Parameters:** -| Name | Type | Description | -|-----------------|---------|----------------------------------------------------------------------------------------| -| environment* | string | Environment for which you want to open gateway. One of `sandbox` or `production` | -| logo | string | Pass an URL of your brand logo. **Note:** Pass an optimised image url for best results | -| theme | string | Options for changing the appearance of the gateway. See below for options under it. | +| Name | Type | Description | +|-----------------|---------|---------------------------------------------------------------------------------------------| +| environment* | string | Environment for which you want to open gateway. One of `sandbox` or `production` | +| logo | string | Pass an URL of your brand logo. **Note:** Pass an optimised image url for best results | +| theme | string | Options for changing the appearance of the gateway. See below for options under it. | +| serviceMode* | string | ServiceMode can be OTP/FACE/IRIS/FP you can set based on your requirment| **Theme:** @@ -140,9 +140,17 @@ Add required permissions in the manifest file. Note - This is the common SDK for /** Required for geotagging */ + + /** Required for ID card analysis, selfie and face match**/ + + + + + + ``` A fintech Android app can't access the following permission - Read_external_storage @@ -152,6 +160,26 @@ A fintech Android app can't access the following permission - Read_phone_numbers - Read_media_videos +## You get a build error due to a theme issue. +- Please add tools:replace="android:theme" under your android manifest. +``` + + ..... + + +``` +## You get a build error due to a duplicate class android.support.v4 +- Check your gradle.properties below should be added. +``` +android.enableJetifier=true +reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 + +``` + ### IOS Permission Permissions need to add in your info.plist diff --git a/android/build.gradle b/android/build.gradle index ca78b2a..a5290a9 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -88,32 +88,58 @@ dependencies { // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" - implementation 'com.github.digio-tech:gateway:v4.0.14' - compileOnly 'com.github.digio-tech:gateway_kyc:v4.0.20' - implementation 'com.github.digio-tech:gateway_esign:4.0.12' - // compileOnly fileTree(dir: "libs", include: ["*.aar"]) - implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'com.google.android.material:material:1.9.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation "androidx.camera:camera-core:1.2.2" - 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:2.5.3' - implementation 'androidx.navigation:navigation-ui:2.5.3' - implementation 'androidx.preference:preference:1.2.0' - implementation 'com.google.android.gms:play-services-mlkit-face-detection:17.1.0' - implementation 'com.google.android.gms:play-services-location:21.0.1' - implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' - - compileOnly 'com.github.digio-tech:protean-esign:v3.2' - implementation 'com.android.volley:volley:1.2.1' - implementation 'com.scottyab:rootbeer-lib:0.1.0' - - implementation 'com.squareup.okhttp3:okhttp:4.10.0' - implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0' - implementation 'com.github.digio-tech:cvl_esign:v1.0.1' - implementation 'com.github.digio-tech:cvl_rdservice:v1.0.0' - implementation 'com.google.code.gson:gson:2.9.1' +// core dependencies + implementation(platform("com.github.digio-tech:digio-bom:v1.0.10")) + 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") + + implementation("androidx.swiperefreshlayout:swiperefreshlayout") + implementation("com.android.volley:volley") + implementation("com.squareup.okhttp3:okhttp") + implementation("com.squareup.okhttp3:logging-interceptor") + implementation("com.google.code.gson:gson") + implementation("com.github.digio-tech:digio_permissions") + implementation("com.google.android.gms:play-services-location") + + implementation("com.github.digio-tech:sdk_offlinekyc") + + implementation("com.github.digio-tech:esign_otp") + compileOnly("com.github.digio-tech:protean-esign") + implementation("com.github.digio-tech:cvl_esign") + implementation("com.scottyab:rootbeer-lib") + implementation("com.afollestad.material-dialogs:core") //giving duplicate class with upi + + implementation("com.github.digio-tech:esign_biometrics") + implementation("com.github.digio-tech:cvl_rdservice") + + implementation("com.github.digio-tech:esign_mandate") + + implementation("com.github.digio-tech:sdk_native_camera") + implementation("com.github.digio-tech:image_processor") + implementation("androidx.exifinterface:exifinterface") + + implementation("com.github.digio-tech:sdk_ml_camera") + implementation("com.google.mlkit:face-detection") + implementation("androidx.camera:camera-core") + implementation("androidx.camera:camera-camera2") + implementation("androidx.camera:camera-lifecycle") + implementation("androidx.camera:camera-view") + implementation("androidx.camera:camera-video") + implementation("androidx.preference:preference-ktx") + implementation("androidx.exifinterface:exifinterface") + + implementation("com.github.digio-tech:sdk_upi") + implementation("androidx.core:core-ktx") + implementation("com.squareup.retrofit2:retrofit") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core") + implementation("androidx.fragment:fragment-ktx") + implementation("androidx.lifecycle:lifecycle-livedata-ktx") + implementation("com.squareup.retrofit2:converter-gson") + } diff --git a/android/src/main/java/com/digioreactnative/DigioReactNativeModule.java b/android/src/main/java/com/digioreactnative/DigioReactNativeModule.java index 21fc902..c1a64b9 100644 --- a/android/src/main/java/com/digioreactnative/DigioReactNativeModule.java +++ b/android/src/main/java/com/digioreactnative/DigioReactNativeModule.java @@ -37,15 +37,17 @@ import in.digio.sdk.gateway.DigioActivity; import in.digio.sdk.gateway.DigioConstants; import in.digio.sdk.gateway.enums.DigioEnvironment; +import in.digio.sdk.gateway.enums.DigioServiceMode; import in.digio.sdk.gateway.enums.DigioErrorCode; import in.digio.sdk.gateway.model.DigioConfig; import in.digio.sdk.gateway.model.DigioTheme; + @ReactModule(name = DigioReactNativeModule.NAME) public class DigioReactNativeModule extends ReactContextBaseJavaModule implements LifecycleEventListener { public static final String NAME = "DigioReactNative"; - public static final String AAR_VERSION = "4.0.8"; + public static final String AAR_VERSION = "5.0.1"; public static final int DIGIO_ACTIVITY = 73457843; private Promise resultPromise; private boolean isReceiverRegistered = false; @@ -55,17 +57,19 @@ public class DigioReactNativeModule extends ReactContextBaseJavaModule implement @Override public void onReceive(Context context, Intent intent) { - if (intent.getStringExtra("data") != null) { + if (intent.getStringExtra("updateGatewayEvent") != null) { +// if (intent.getStringExtra("data") != null) { JSONObject jsonObject = null; try { jsonObject = new JSONObject( - intent.getStringExtra( - "data" - ) +// intent.getStringExtra("data") + intent.getStringExtra("updateGatewayEvent") ); } catch (JSONException e) { e.printStackTrace(); } + // Log.e("CheckResponse"," gatewayEvent "+jsonObject); + WritableMap resultMap = MapUtil.jsonToWritableMap(jsonObject); getReactApplicationContext() .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) @@ -78,7 +82,8 @@ public void onReceive(Context context, Intent intent) { @Override public void onActivityResult(Activity activity, int requestCode, int resultCode, @Nullable Intent intent) { if (requestCode == DIGIO_ACTIVITY) { - onNativeActivityResult(resultCode, intent); + int responseCode = intent.getIntExtra("responseCode", 0); + onNativeActivityResult(responseCode, intent); } } @@ -92,16 +97,19 @@ private void onNativeActivityResult(int resultCode, Intent data) { WritableMap resultMap = Arguments.createMap(); resultMap.putInt("code", resultCode); if (data != null) { + // Log.e("CheckResponse"," resultCode "+resultCode+ " data "+data.getDataString()); + resultMap.putString("message", data.getStringExtra("message")); - String screenName = data.getStringExtra("screen_name"); + String screenName = data.getStringExtra("currentState"); +// String screenName = data.getStringExtra("screen_name"); if (TextUtils.isEmpty(screenName)) { screenName = "starting_digio"; } resultMap.putString("screen", screenName); resultMap.putString("step", data.getStringExtra("step")); resultMap.putString("documentId", data.getStringExtra("document_id")); - resultMap.putString("failingUrl", data.getStringExtra("failing_url")); - resultMap.putInt("errorCode", data.getIntExtra("error_code", resultCode)); + resultMap.putString("failingUrl", data.getStringExtra("failingUrl")); + resultMap.putInt("errorCode", data.getIntExtra("errorCode", resultCode)); String[] stringArrayExtra = data.getStringArrayExtra("permissions"); WritableArray permissionArray = Arguments.createArray(); if (stringArrayExtra != null && stringArrayExtra.length > 0) { @@ -142,7 +150,7 @@ public void onHostResume() { compatRegisterReceiver(this.getReactApplicationContext(), eventBroadcastReceiver, filter, true); isReceiverRegistered = true; } - + } @Override @@ -174,14 +182,17 @@ private void compatRegisterReceiver(Context context, BroadcastReceiver receiver, } } - @ReactMethod +@ReactMethod public void start(String documentId, String identifier, String tokenId, ReadableMap additionalData, ReadableMap config, Promise promise) { this.resultPromise = promise; try { Intent intent = new Intent(this.getCurrentActivity(), DigioActivity.class); + // set everything under digioConfig DigioConfig digioConfig = new DigioConfig(); String environment = config.getString("environment"); String logo = config.getString("logo"); + String mode = config.getString("mode"); + // Log.e("Digio_mode ", ""+mode); if (!TextUtils.isEmpty(environment)) { try { digioConfig.setEnvironment(DigioEnvironment.valueOf(environment.toUpperCase(Locale.ENGLISH))); @@ -217,17 +228,16 @@ public void start(String documentId, String identifier, String tokenId, Readable digioConfig.setTheme(digioTheme); - intent.putExtra("config", digioConfig); - intent.putExtra("aar_version", AAR_VERSION); - if (documentId.startsWith("ENA") || documentId.startsWith("DID")) { - intent.putExtra("navigation_graph", in.digio.sdk.esign.R.navigation.esign); - } else { - intent.putExtra("navigation_graph", in.digio.sdk.kyc.R.navigation.workflow); + digioConfig.setAarVersion(AAR_VERSION); + if (!TextUtils.isEmpty(mode)) { + digioConfig.setServiceMode(DigioServiceMode.valueOf(mode.toUpperCase(Locale.ENGLISH))); } - intent.putExtra("document_id", documentId); - intent.putExtra("customer_identifier", identifier); - intent.putExtra("token_id", tokenId); + digioConfig.setGToken(tokenId); + digioConfig.setRequestId(documentId); + digioConfig.setUserIdentifier(identifier); + digioConfig.setLinkApproach(false); + HashMap additionalDataMap = new HashMap(); if (additionalData != null) { Iterator> entryIterator = additionalData.getEntryIterator(); @@ -236,7 +246,9 @@ public void start(String documentId, String identifier, String tokenId, Readable additionalDataMap.put(objectEntry.getKey(), objectEntry.getValue()); } } - intent.putExtra("additional_data", additionalDataMap); + digioConfig.setAdditionalData(additionalDataMap); + intent.putExtra("config", digioConfig); + this.getCurrentActivity().startActivityForResult(intent, DIGIO_ACTIVITY); } catch (Exception e) { // Throws DigioException if WorkflowResponseListener is not implemented/passed, or diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 383c301..a03abdf 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -101,13 +101,17 @@ android { proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } + buildFeatures { + viewBinding true + dataBinding true + } } dependencies { // The version of react-native is set by the React Native Gradle Plugin implementation("com.facebook.react:react-android") // implementation fileTree(dir: 'libs', include: ['*.aar']) - implementation 'com.github.digio-tech:gateway_kyc:v4.0.20' +// implementation 'com.github.digio-tech:gateway_kyc:v4.0.20' implementation 'com.github.digio-tech:protean-esign:v3.2' debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 7090f11..b823591 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,20 +1,31 @@ - + - /** Required for geotagging */ + - /** Required for ID card analysis, selfie and face match**/ + + - + + + + + + + + + + + diff --git a/example/android/build.gradle b/example/android/build.gradle index eb55bfe..bb936a4 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -3,7 +3,7 @@ buildscript { ext { buildToolsVersion = "33.0.0" - minSdkVersion = 23 + minSdkVersion = 24 compileSdkVersion = 34 targetSdkVersion = 34 diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 3fa8b18..906ea7e 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,7 +1,7 @@ PODS: - boost (1.83.0) - CocoaAsyncSocket (7.6.5) - - digio-react-native (1.0.16): + - digio-react-native (1.0.18): - DigioEsignSDK - DigiokycSDK - glog @@ -1320,7 +1320,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost: d3f49c53809116a5d38da093a8aa78bf551aed09 CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 - digio-react-native: f18f3a25e0852f678ed919347c2509e641bd47dc + digio-react-native: f712bacb613a622eefdd711dd4772bc50f00c26a DigioEsignSDK: a83db91acf10a043ba06da5d56aa976b64eb0c48 DigiokycSDK: 198d94e5856735c791ee6ca475cb5f78fc333210 DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953 diff --git a/example/src/App.tsx b/example/src/App.tsx index b50ad73..6dc9b46 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,26 +1,35 @@ -import * as React from 'react'; - +import React, { useState, useEffect } from 'react'; import { StyleSheet, View, Text } from 'react-native'; -import { Digio, Environment } from '@digiotech/react-native'; +import { Digio, Environment, ServiceMode } from '@digiotech/react-native'; import type { GatewayEvent } from '@digiotech/react-native'; export default function App() { - React.useEffect(() => { - const digio = new Digio({ environment: Environment.PRODUCTION }); + const [digioResult, setDigioResult] = useState(null); + const [digioEvent, setDigioEvent] = useState(null); + + useEffect(() => { + const digio = new Digio({ environment: Environment.PRODUCTION, serviceMode: ServiceMode.OTP }); const digioGatewayEventSubscription = digio.addGatewayEventListener( (event: GatewayEvent) => { console.log('Digio_event ' + event.event); + if (event.event !== undefined) { + setDigioEvent(event.event); + } } ); + digio .start( - 'DID241223192125925KXC9OHUYPF8T3J', + 'KID250220172348723LZOELQQ99NSVSP', 'akash.kumar@digio.in', - 'GWT24122319212682868JPKWC1M6MRJS' + 'GWT250220172348753FOJYJA8DXAU2OS' ) .then((res) => { console.log(res); + if (res !== undefined) { + setDigioResult(res); + } }) .catch((err) => console.error(err)); @@ -32,6 +41,14 @@ export default function App() { return ( Digio Starting + + Result: + {digioResult ? JSON.stringify(digioResult) : 'Waiting...'} + + + Event: + {digioEvent ? digioEvent : 'Waiting...'} + ); } @@ -42,9 +59,16 @@ const styles = StyleSheet.create({ alignItems: 'center', justifyContent: 'center', }, - box: { - width: 60, - height: 60, - marginVertical: 20, + resultContainer: { + marginTop: 20, + padding: 10, + backgroundColor: '#f0f0f0', + borderRadius: 5, + }, + eventContainer: { + marginTop: 20, + padding: 10, + backgroundColor: '#e0e0e0', + borderRadius: 5, }, }); diff --git a/package.json b/package.json index da27588..65ad43b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@digiotech/react-native", - "version": "1.0.18", + "version": "2.0.1", "description": "SDK for invoking client side journey for any of Digio request", "main": "lib/commonjs/index", "module": "lib/module/index", diff --git a/src/index.ts b/src/index.ts index 53c2f53..3b97933 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,6 +10,7 @@ import type { DigioResponse } from './types/interfaces/digio_response'; import type { GatewayEvent } from './types/interfaces/gateway_event'; export { Environment } from './types/enums/environment'; +export { ServiceMode } from './types/enums/service_mode'; const LINKING_ERROR = `The package 'digio-react-native' doesn't seem to be linked. Make sure: \n\n` + @@ -85,6 +86,7 @@ export class Digio { return { environment: this.config.environment, logo: this.config.logo, + mode: this.config.serviceMode, ...this.config.theme, }; } diff --git a/src/types/enums/service_mode.ts b/src/types/enums/service_mode.ts new file mode 100644 index 0000000..dbb2314 --- /dev/null +++ b/src/types/enums/service_mode.ts @@ -0,0 +1,6 @@ +export enum ServiceMode { + OTP = 'OTP', + FP = 'FP', + IRIS = 'IRIS', + FACE = 'FACE', +} \ No newline at end of file diff --git a/src/types/interfaces/digio_config.ts b/src/types/interfaces/digio_config.ts index faa2fe2..5d2b3cf 100644 --- a/src/types/interfaces/digio_config.ts +++ b/src/types/interfaces/digio_config.ts @@ -1,8 +1,10 @@ import { Environment } from '../enums/environment'; +import type { ServiceMode } from '../enums/service_mode'; import type { Theme } from './theme'; export interface DigioConfig { logo?: string; environment?: Environment; theme?: Theme; + serviceMode?: ServiceMode; }