@digiotech/react-native 1.0.0 → 1.0.1-4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Digio React Native SDK
2
2
 
3
+ [![npm version](https://badge.fury.io/js/@digiotech%2Freact-native.svg)](https://badge.fury.io/js/@digiotech%2Freact-native)
4
+
3
5
  Official React Native SDK for Digio Gateway Integration
4
6
 
5
7
  ## Installation
@@ -10,7 +12,7 @@ yarn install @digiotech/react-native
10
12
 
11
13
  ## Documentation
12
14
 
13
- Documentation of Digio Gateway Integration and their usage is available at <https://documentation.digio.in>
15
+ Documentation of Digio Gateway Integration and their usage
14
16
 
15
17
  ### Basic Usage
16
18
 
@@ -82,6 +84,17 @@ function YourComponent() {
82
84
  }
83
85
  ```
84
86
 
87
+ ## Android
88
+ #### Note: Incase you are using camera feature and facing black screen on camera then follow below steps
89
+ - 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)
90
+
91
+
92
+ - Add below in your project under build.gradle file inside dependencies
93
+
94
+ ```tsx
95
+ implementation fileTree(dir: 'libs', include: ['*.aar'])
96
+ ```
97
+
85
98
  ## SDK Reference
86
99
 
87
100
  ### DigioConfig
@@ -112,3 +125,45 @@ function YourComponent() {
112
125
  | documentId | string | Document ID Passed from the parent app. For eg: `KID22040413040490937VNTC6LAP8KWD` |
113
126
  | message | string | Error message in case of crash or failure |
114
127
  | permissions | Array<string> | List of mandatory permissions which are not given during kyc journey |
128
+
129
+ ### Android Permissions
130
+
131
+ Add required permissions in the manifest file. Note - This is the common SDK for various KYC flows
132
+
133
+ ```
134
+ <!--RECORD_AUDIO and MODIFY_AUDIO_SETTINGS Permission required for Video KYC -->
135
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
136
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
137
+ /** Required for geotagging */
138
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
139
+ /** Required for ID card analysis, selfie and face match**/
140
+ <uses-permission android:name="android.permission.CAMERA" />
141
+ <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
142
+ ```
143
+ A fintech Android app can't access the following permission
144
+ - Read_external_storage
145
+ - Read_media_images
146
+ - Read_contacts
147
+ - Access_fine_location
148
+ - Read_phone_numbers
149
+ - Read_media_videos
150
+
151
+ ### IOS Permission
152
+
153
+ Permissions need to add in your info.plist
154
+ ```
155
+ /** Camera permission incase of selfie/video KYC/ capture document **/
156
+ <key>NSCameraUsageDescription</key>
157
+ <string>$(PRODUCT_NAME) would like to access your camera.</string>
158
+ <key>NSPhotoLibraryUsageDescription</key>
159
+ <string>$(PRODUCT_NAME) would like to access your photo.</string>
160
+ /** Microphone permission incase of video KYC **/
161
+ <key>NSMicrophoneUsageDescription</key>
162
+ <string>$(PRODUCT_NAME) would like to access your microphone to capture video.</string>
163
+ /** Location permission for geo tagging for camera/video kyc/ selfie **/
164
+ <key>NSLocationWhenInUseUsageDescription</key>
165
+ <string>$(PRODUCT_NAME) would like to access your location.</string>
166
+ <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
167
+ <string>$(PRODUCT_NAME) would like to access your location.</string>
168
+ ```
169
+ Note : All permissions should be checked and taken before triggering Digio SDK
@@ -74,6 +74,7 @@ android {
74
74
  viewBinding true
75
75
  dataBinding true
76
76
  }
77
+ buildToolsVersion '33.0.0'
77
78
  }
78
79
 
79
80
  repositories {
@@ -87,20 +88,26 @@ dependencies {
87
88
  // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
88
89
  //noinspection GradleDynamicVersion
89
90
  implementation "com.facebook.react:react-native:+"
90
- implementation 'com.github.digio-tech:gateway:v4.0.8'
91
- implementation 'com.github.digio-tech:gateway_kyc:v4.0.8'
91
+ implementation 'com.github.digio-tech:gateway:v4.0.10'
92
+ compileOnly 'com.github.digio-tech:gateway_kyc:v4.0.15'
93
+ implementation 'com.github.digio-tech:gateway_esign:4.0.8_beta1'
94
+ // compileOnly fileTree(dir: "libs", include: ["*.aar"])
92
95
  implementation 'androidx.appcompat:appcompat:1.6.1'
93
96
  implementation 'com.google.android.material:material:1.9.0'
94
97
  implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
95
- implementation "androidx.camera:camera-core:1.1.0"
96
- implementation "androidx.camera:camera-camera2:1.1.0"
97
- implementation "androidx.camera:camera-lifecycle:1.1.0"
98
- implementation "androidx.camera:camera-view:1.1.0"
98
+ implementation "androidx.camera:camera-core:1.2.2"
99
+ implementation "androidx.camera:camera-camera2:1.2.2"
100
+ implementation "androidx.camera:camera-lifecycle:1.2.2"
101
+ implementation "androidx.camera:camera-view:1.2.2"
99
102
  implementation 'androidx.navigation:navigation-fragment:2.5.3'
100
103
  implementation 'androidx.navigation:navigation-ui:2.5.3'
101
104
  implementation 'androidx.preference:preference:1.2.0'
102
105
  implementation 'com.google.android.gms:play-services-mlkit-face-detection:17.1.0'
103
106
  implementation 'com.google.android.gms:play-services-location:21.0.1'
104
107
  implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
108
+
109
+ compileOnly 'com.github.digio-tech:protean-esign:v3.2'
110
+ implementation 'com.android.volley:volley:1.2.1'
111
+ implementation 'com.scottyab:rootbeer-lib:0.1.0'
105
112
  }
106
113
 
@@ -1,5 +1,6 @@
1
1
  package com.digioreactnative;
2
2
 
3
+ import android.util.Log;
3
4
  import android.annotation.SuppressLint;
4
5
  import android.app.Activity;
5
6
  import android.content.BroadcastReceiver;
@@ -10,10 +11,10 @@ import android.text.TextUtils;
10
11
 
11
12
  import androidx.annotation.NonNull;
12
13
  import androidx.annotation.Nullable;
13
- import androidx.core.content.ContextCompat;
14
14
 
15
15
  import com.facebook.react.bridge.ActivityEventListener;
16
16
  import com.facebook.react.bridge.Arguments;
17
+ import com.facebook.react.bridge.LifecycleEventListener;
17
18
  import com.facebook.react.bridge.Promise;
18
19
  import com.facebook.react.bridge.ReactApplicationContext;
19
20
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
@@ -40,12 +41,14 @@ import in.digio.sdk.gateway.model.DigioConfig;
40
41
  import in.digio.sdk.gateway.model.DigioTheme;
41
42
 
42
43
  @ReactModule(name = DigioReactNativeModule.NAME)
43
- public class DigioReactNativeModule extends ReactContextBaseJavaModule {
44
+ public class DigioReactNativeModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
44
45
  public static final String NAME = "DigioReactNative";
45
46
 
46
47
  public static final String AAR_VERSION = "4.0.8";
47
48
  public static final int DIGIO_ACTIVITY = 73457843;
48
49
  private Promise resultPromise;
50
+ private boolean isReceiverRegistered = false;
51
+
49
52
 
50
53
  private BroadcastReceiver eventBroadcastReceiver = new BroadcastReceiver() {
51
54
 
@@ -127,11 +130,30 @@ public class DigioReactNativeModule extends ReactContextBaseJavaModule {
127
130
  public DigioReactNativeModule(ReactApplicationContext reactContext) {
128
131
  super(reactContext);
129
132
  reactContext.addActivityEventListener(activityEventListener);
130
- ContextCompat.registerReceiver(
131
- reactContext, eventBroadcastReceiver,
132
- new IntentFilter(DigioConstants.GATEWAY_EVENT),
133
- ContextCompat.RECEIVER_NOT_EXPORTED
134
- );
133
+ this.getReactApplicationContext().addLifecycleEventListener(this);
134
+ }
135
+
136
+ @Override
137
+ public void onHostResume() {
138
+ if (!isReceiverRegistered) {
139
+ IntentFilter filter = new IntentFilter(DigioConstants.GATEWAY_EVENT);
140
+ this.getReactApplicationContext().registerReceiver(eventBroadcastReceiver, filter);
141
+ isReceiverRegistered = true;
142
+ }
143
+
144
+ }
145
+
146
+ @Override
147
+ public void onHostPause() {
148
+ // this.getReactApplicationContext().unregisterReceiver(eventBroadcastReceiver);
149
+ }
150
+
151
+ @Override
152
+ public void onHostDestroy() {
153
+ if (isReceiverRegistered) {
154
+ this.getReactApplicationContext().unregisterReceiver(eventBroadcastReceiver);
155
+ isReceiverRegistered = false;
156
+ }
135
157
  }
136
158
 
137
159
  @Override
@@ -185,7 +207,12 @@ public class DigioReactNativeModule extends ReactContextBaseJavaModule {
185
207
 
186
208
  intent.putExtra("config", digioConfig);
187
209
  intent.putExtra("aar_version", AAR_VERSION);
188
- intent.putExtra("navigation_graph", R.navigation.workflow);
210
+ if (documentId.startsWith("ENA") || documentId.startsWith("DID")) {
211
+ intent.putExtra("navigation_graph", in.digio.sdk.esign.R.navigation.esign);
212
+ } else {
213
+ intent.putExtra("navigation_graph", in.digio.sdk.kyc.R.navigation.workflow);
214
+ }
215
+
189
216
  intent.putExtra("document_id", documentId);
190
217
  intent.putExtra("customer_identifier", identifier);
191
218
  intent.putExtra("token_id", tokenId);
@@ -15,8 +15,10 @@ Pod::Spec.new do |s|
15
15
  s.source = { :git => "https://github.com/digio-tech/reactnative-sdk.git", :tag => "#{s.version}" }
16
16
 
17
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
18
-
19
- s.dependency 'DigiokycSDK', '~> 1.1.0'
18
+ # enable below to run local xcframework
19
+ # s.vendored_frameworks = 'ios/DigiokycSDK.xcframework'
20
+ s.dependency 'DigiokycSDK'
21
+ s.dependency 'DigioEsignSDK'
20
22
 
21
23
  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
22
24
  # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
@@ -2,11 +2,13 @@ import DigiokycSDK
2
2
  import React
3
3
  import UIKit
4
4
  import Foundation
5
+ import DigioEsignSDK
5
6
 
6
7
  @objc(DigioReactNative)
7
- class DigioReactNative: RCTEventEmitter, DigioKycResponseDelegate {
8
+ class DigioReactNative: RCTEventEmitter, DigioKycResponseDelegate,DigioEsignDelegate {
9
+
8
10
  var result: RCTPromiseResolveBlock!
9
-
11
+
10
12
  override func supportedEvents() -> [String]! {
11
13
  return ["gatewayEvent"]
12
14
  }
@@ -28,31 +30,24 @@ class DigioReactNative: RCTEventEmitter, DigioKycResponseDelegate {
28
30
  var fontFamily: String?
29
31
  var fontUrl: String?
30
32
  var environment: String = "production"
31
-
33
+
32
34
  additionalParams = additionalData as? [String : String];
33
-
35
+
34
36
  environment = config?["environment"] as? String ?? "production";
35
37
  primaryColor = config?["primaryColor"] as? String;
36
38
  logo = config?["logo"] as? String;
37
39
  fontFormat = config?["fontFormat"] as? String;
38
40
  fontFamily = config?["fontFamily"] as? String;
39
41
  fontUrl = config?["fontUrl"] as? String;
40
-
41
- // Your existing code here...
42
- try DigioKycBuilder()
43
- .withController(viewController: rootViewController!)
44
- .setDocumentId(documentId: documentId)
45
- .setKycResponseDelegate(delegate: self)
46
- .setIdentifier(identifier: identifier)
47
- .setEnvironment(environment: environment.elementsEqual("sandbox") ? DigioEnvironment.SANDBOX : DigioEnvironment.PRODUCTION)
48
- .setPrimaryColor(hexColor: primaryColor ?? "")
49
- .setTokenId(tokenId: tokenId ?? "")
50
- .setFontFormat(fontFormat: fontFormat ?? "")
51
- .setFontFamily(fontFamily: fontFamily ?? "")
52
- .setFontUrl(fontUrl: fontUrl ?? "")
53
- .setLogo(logo: logo ?? "")
54
- .setAdditionalParams(additionalParams: additionalParams ?? [:])
55
- .build()
42
+
43
+ if documentId.hasPrefix("ENA") || documentId.hasPrefix("DID") {
44
+ try self.startSign(rootViewController: rootViewController!, documentId: documentId, identifier: identifier, tokenId: tokenId, environment: environment, primaryColor: primaryColor, fontFormat: fontFormat, fontFamily: fontFamily, fontUrl: fontUrl, logo: logo, additionalParams: additionalParams)
45
+ .build()
46
+ }else{
47
+ try self.startKyc(rootViewController: rootViewController!, documentId: documentId, identifier: identifier, tokenId: tokenId, environment: environment, primaryColor: primaryColor, fontFormat: fontFormat, fontFamily: fontFamily, fontUrl: fontUrl, logo: logo, additionalParams: additionalParams)
48
+ .build()
49
+ }
50
+
56
51
  } catch let error {
57
52
  print("Exception --> \(error.localizedDescription)")
58
53
  }
@@ -61,7 +56,46 @@ class DigioReactNative: RCTEventEmitter, DigioKycResponseDelegate {
61
56
  }
62
57
  }
63
58
  }
64
- //
59
+
60
+ private func startKyc(rootViewController: UIViewController,documentId: String, identifier: String, tokenId: String?,
61
+ environment: String,primaryColor: String?,fontFormat: String?,
62
+ fontFamily: String?,fontUrl: String?,logo: String?,additionalParams: [String:String]?) -> DigioKycBuilder {
63
+ print("...........starting kyc.............")
64
+ return DigioKycBuilder()
65
+ .withController(viewController: rootViewController)
66
+ .setDocumentId(documentId: documentId)
67
+ .setKycResponseDelegate(delegate: self)
68
+ .setIdentifier(identifier: identifier)
69
+ .setEnvironment(environment: environment.elementsEqual("sandbox") ? DigioEnvironment.SANDBOX : DigioEnvironment.PRODUCTION)
70
+ .setPrimaryColor(hexColor: primaryColor ?? "")
71
+ .setTokenId(tokenId: tokenId ?? "")
72
+ .setFontFormat(fontFormat: fontFormat ?? "")
73
+ .setFontFamily(fontFamily: fontFamily ?? "")
74
+ .setFontUrl(fontUrl: fontUrl ?? "")
75
+ .setLogo(logo: logo ?? "")
76
+ .setAdditionalParams(additionalParams: additionalParams ?? [:])
77
+
78
+ }
79
+
80
+ private func startSign(rootViewController: UIViewController,documentId: String, identifier: String, tokenId: String?,
81
+ environment: String,primaryColor: String?,fontFormat: String?,fontFamily: String?,fontUrl: String?,logo: String?,additionalParams: [String:String]?) -> DigioBuilder{
82
+ print("...........starting sign.............")
83
+ return DigioBuilder()
84
+ .withController(viewController: rootViewController)
85
+ .setDocumentId(documentId: documentId)
86
+ // .setDelegate(delegate: self)
87
+ .setIdentifier(identifier: identifier)
88
+ .setEnvironment(environment: environment.elementsEqual("sandbox") ? DigioEnvironment.SANDBOX : DigioEnvironment.PRODUCTION)
89
+ .setPrimaryColor(hexColor: primaryColor ?? "")
90
+ .setTokenId(tokenId: tokenId ?? "")
91
+ .setFontFormat(fontFormat: fontFormat ?? "")
92
+ .setFontFamily(fontFamily: fontFamily ?? "")
93
+ .setFontUrl(fontUrl: fontUrl ?? "")
94
+ .setLogo(logo: logo ?? "")
95
+ .setAdditionalParams(additionalParams: additionalParams ?? [:])
96
+ .setServiceMode(serviceMode: DigioServiceMode.OTP)
97
+ }
98
+
65
99
  private func formatJson(response: String)->[String: Any]{
66
100
  let kycResponse = try! JSONDecoder().decode(DigioKycResponse.self, from: response.data(using: .utf8)!)
67
101
  var resultMap: [String: Any] = [:]
@@ -82,6 +116,7 @@ class DigioReactNative: RCTEventEmitter, DigioKycResponseDelegate {
82
116
  return resultMap
83
117
  }
84
118
 
119
+ /** Kyc sdk callback */
85
120
  func onDigioKycResponseSuccess(successResponse: String) {
86
121
  print("Success \(successResponse)")
87
122
  if self.result != nil {
@@ -100,7 +135,7 @@ class DigioReactNative: RCTEventEmitter, DigioKycResponseDelegate {
100
135
  print("Gateway event \(event)")
101
136
  self.sendEvent(withName: "gatewayEvent", body: convertToDictionary(text: event))
102
137
  }
103
-
138
+
104
139
  func convertToDictionary(text: String) -> [String: Any]? {
105
140
  if let data = text.data(using: .utf8) {
106
141
  do {
@@ -111,4 +146,26 @@ class DigioReactNative: RCTEventEmitter, DigioKycResponseDelegate {
111
146
  }
112
147
  return nil
113
148
  }
149
+ /** esign sdk callbacks */
150
+
151
+ func onDigioResponseSuccess(response: String) {
152
+ print("Success esign \(response)")
153
+ if self.result != nil {
154
+ self.result(formatJson(response: response))
155
+ }
156
+ }
157
+
158
+ func onDigioResponseFailure(response: String) {
159
+ print("Failure esign \(response)")
160
+ if self.result != nil {
161
+ self.result(formatJson(response: response))
162
+ }
163
+ }
164
+
165
+ func onGatewayEvent(event: String) {
166
+ print("onGatewayEvent esign \(event)")
167
+ self.sendEvent(withName: "gatewayEvent", body: convertToDictionary(text: event))
168
+ }
169
+
170
+
114
171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digiotech/react-native",
3
- "version": "1.0.0",
3
+ "version": "1.0.14.1",
4
4
  "description": "SDK for invoking client side journey for any of Digio request",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",