@digiotech/react-native 1.0.10 → 1.0.12

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.
@@ -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.10",
3
+ "version": "1.0.12",
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",