assentify-sdk-react-native 0.0.36 → 0.0.38
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 +17 -0
- package/android/build.gradle +1 -1
- package/android/src/main/AndroidManifest.xml +6 -0
- package/android/src/main/java/com/assentifysdk/AssentifySdkModule.kt +18 -16
- package/android/src/main/java/com/assentifysdk/QrActivity.kt +363 -0
- package/android/src/main/res/layout/activity_qr.xml +233 -0
- package/assentify-sdk.podspec +1 -1
- package/ios/NativeAssentifySdk.mm +4 -5
- package/ios/NativeAssentifySdk.swift +30 -18
- package/ios/View/PassportController.swift +6 -2
- package/ios/View/QrController.swift +213 -0
- package/lib/commonjs/AssentifyProvider.js +21 -0
- package/lib/commonjs/AssentifyProvider.js.map +1 -1
- package/lib/commonjs/AssentifyWrapper.js +6 -2
- package/lib/commonjs/AssentifyWrapper.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/AssentifyProvider.js +21 -0
- package/lib/module/AssentifyProvider.js.map +1 -1
- package/lib/module/AssentifyWrapper.js +6 -2
- package/lib/module/AssentifyWrapper.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/example/src/Home.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/AssentifyProvider.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/AssentifyWrapper.d.ts +2 -1
- package/lib/typescript/lib/commonjs/AssentifyWrapper.d.ts.map +1 -1
- package/lib/typescript/lib/module/AssentifyProvider.d.ts.map +1 -1
- package/lib/typescript/lib/module/AssentifyWrapper.d.ts +2 -1
- package/lib/typescript/lib/module/AssentifyWrapper.d.ts.map +1 -1
- package/lib/typescript/lib/module/index.d.ts +2 -1
- package/lib/typescript/lib/module/index.d.ts.map +1 -1
- package/lib/typescript/src/AssentifyProvider.d.ts.map +1 -1
- package/lib/typescript/src/AssentifyWrapper.d.ts +2 -1
- package/lib/typescript/src/AssentifyWrapper.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +2 -0
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/AssentifyProvider.tsx +17 -0
- package/src/AssentifyWrapper.ts +5 -10
- package/src/types.ts +3 -0
package/README.md
CHANGED
|
@@ -93,6 +93,23 @@ yarn add assentify-sdk-react-native
|
|
|
93
93
|
|
|
94
94
|
## Versions
|
|
95
95
|
|
|
96
|
+
**0.0.38**
|
|
97
|
+
1. *Fixes issues related to old swift versions*
|
|
98
|
+
|
|
99
|
+
**0.0.37**
|
|
100
|
+
1. *New Feature: QR Scan*
|
|
101
|
+
- **QR code scanning**, allowing users to scan QR codes from the documents that have QR.
|
|
102
|
+
|
|
103
|
+
2. *Simplified SDK Initialization*
|
|
104
|
+
- You no longer need to pass the following parameters when initializing the SDK:
|
|
105
|
+
- `processMrz`
|
|
106
|
+
- `performLivenessDocument`
|
|
107
|
+
- `performPassiveLivenessFace`
|
|
108
|
+
- `saveCapturedVideo`
|
|
109
|
+
- `storeCapturedDocument`
|
|
110
|
+
- `storeImageStream`
|
|
111
|
+
- These options are now fully configurable from the **portal**, removing the need for extra code changes.
|
|
112
|
+
|
|
96
113
|
**0.0.36**
|
|
97
114
|
- Face match improvements
|
|
98
115
|
|
package/android/build.gradle
CHANGED
|
@@ -99,7 +99,7 @@ dependencies {
|
|
|
99
99
|
implementation "com.facebook.react:react-native:+"
|
|
100
100
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
101
101
|
|
|
102
|
-
implementation 'com.github.AssentifyLTD:Assentify.SDK.Android:0.0.
|
|
102
|
+
implementation 'com.github.AssentifyLTD:Assentify.SDK.Android:0.0.88'
|
|
103
103
|
|
|
104
104
|
/* Assentify Sdk Dependencies */
|
|
105
105
|
implementation 'com.google.code.gson:gson:2.8.9'
|
|
@@ -61,12 +61,7 @@ class AssentifySdkModule(context: ReactApplicationContext) :
|
|
|
61
61
|
apiKey: String,
|
|
62
62
|
tenantIdentifier: String,
|
|
63
63
|
instanceHash: String,
|
|
64
|
-
processMrz: Boolean? = null,
|
|
65
|
-
storeCapturedDocument: Boolean? = null,
|
|
66
64
|
performLivenessFace: Boolean? = null,
|
|
67
|
-
storeImageStream: Boolean? = null,
|
|
68
|
-
saveCapturedVideoID: Boolean? = null,
|
|
69
|
-
saveCapturedVideoFace: Boolean? = null,
|
|
70
65
|
ENV_CustomColor: String? = null,
|
|
71
66
|
enableDetect: Boolean = true,
|
|
72
67
|
enableGuide: Boolean = true,
|
|
@@ -106,12 +101,7 @@ class AssentifySdkModule(context: ReactApplicationContext) :
|
|
|
106
101
|
println("$tag apiKey: $apiKey")
|
|
107
102
|
println("$tag tenantIdentifier: $tenantIdentifier")
|
|
108
103
|
println("$tag instanceHash: $instanceHash")
|
|
109
|
-
println("$tag processMrz: $processMrz")
|
|
110
|
-
println("$tag storeCapturedDocument: $storeCapturedDocument")
|
|
111
104
|
println("$tag performLivenessFace: $performLivenessFace")
|
|
112
|
-
println("$tag storeImageStream: $storeImageStream")
|
|
113
|
-
println("$tag saveCapturedVideoID: $saveCapturedVideoID")
|
|
114
|
-
println("$tag saveCapturedVideoFace: $saveCapturedVideoFace")
|
|
115
105
|
println("$tag ENV_CustomColor: $ENV_CustomColor")
|
|
116
106
|
println("$tag enableDetect: $enableDetect")
|
|
117
107
|
println("$tag enableGuide: $enableGuide")
|
|
@@ -177,12 +167,7 @@ class AssentifySdkModule(context: ReactApplicationContext) :
|
|
|
177
167
|
instanceHash,
|
|
178
168
|
environmentalConditions,
|
|
179
169
|
this,
|
|
180
|
-
|
|
181
|
-
storeCapturedDocument,
|
|
182
|
-
performLivenessFace,
|
|
183
|
-
storeImageStream,
|
|
184
|
-
saveCapturedVideoID,
|
|
185
|
-
saveCapturedVideoFace,
|
|
170
|
+
performActiveLivenessFace = performLivenessFace,
|
|
186
171
|
context = reactApplicationContext
|
|
187
172
|
)
|
|
188
173
|
} catch (e: Exception) {
|
|
@@ -224,6 +209,23 @@ class AssentifySdkModule(context: ReactApplicationContext) :
|
|
|
224
209
|
currentActivity?.startActivity(intent)
|
|
225
210
|
}
|
|
226
211
|
|
|
212
|
+
@ReactMethod
|
|
213
|
+
fun startScanQrPage( jsonStringKycDocumentDetails: String,
|
|
214
|
+
language: String,
|
|
215
|
+
stepID :Int) {
|
|
216
|
+
timeStarted = getCurrentDateTimeUTC();
|
|
217
|
+
/** Nav To Other Scan Page */
|
|
218
|
+
val intent = Intent(currentActivity, QrActivity::class.java)
|
|
219
|
+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
220
|
+
intent.putExtra("holdHandColor", environmentalConditions.HoldHandColor)
|
|
221
|
+
intent.putExtra("processingColor", environmentalConditions.CustomColor)
|
|
222
|
+
intent.putExtra("kycDocumentDetails", jsonStringKycDocumentDetails)
|
|
223
|
+
intent.putExtra("language", language)
|
|
224
|
+
intent.putExtra("stepID", stepID)
|
|
225
|
+
intent.putExtra("manualClickColor", this.manualClickColor)
|
|
226
|
+
currentActivity?.startActivity(intent)
|
|
227
|
+
}
|
|
228
|
+
|
|
227
229
|
@ReactMethod
|
|
228
230
|
fun startScanIDPage(
|
|
229
231
|
jsonStringKycDocumentDetails: String,
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
package com.assentifysdk
|
|
2
|
+
|
|
3
|
+
import android.R.drawable
|
|
4
|
+
import android.app.PendingIntent
|
|
5
|
+
import android.content.Intent
|
|
6
|
+
import android.content.res.ColorStateList
|
|
7
|
+
import android.graphics.BitmapFactory
|
|
8
|
+
import android.graphics.Color
|
|
9
|
+
import android.graphics.PorterDuff
|
|
10
|
+
import android.graphics.drawable.Drawable
|
|
11
|
+
import android.os.Build
|
|
12
|
+
import android.os.Bundle
|
|
13
|
+
import android.provider.Settings
|
|
14
|
+
import android.view.View
|
|
15
|
+
import android.widget.Button
|
|
16
|
+
import android.widget.ImageView
|
|
17
|
+
import android.widget.LinearLayout
|
|
18
|
+
import android.widget.ProgressBar
|
|
19
|
+
import android.widget.RelativeLayout
|
|
20
|
+
import android.widget.TextView
|
|
21
|
+
import androidx.appcompat.app.AppCompatActivity
|
|
22
|
+
import androidx.core.content.ContextCompat
|
|
23
|
+
import com.assentify.sdk.AssentifySdk
|
|
24
|
+
import com.assentify.sdk.AssentifySdkObject
|
|
25
|
+
import com.assentify.sdk.Core.Constants.ConstantsValues
|
|
26
|
+
import com.assentify.sdk.Core.Constants.DoneFlags
|
|
27
|
+
import com.assentify.sdk.Core.Constants.Language
|
|
28
|
+
import com.assentify.sdk.ScanPassport.PassportResponseModel
|
|
29
|
+
import com.assentify.sdk.ScanPassport.ScanPassportCallback
|
|
30
|
+
import com.google.gson.Gson
|
|
31
|
+
import com.assentify.sdk.ScanIDCard.IDResponseModel
|
|
32
|
+
import com.assentify.sdk.Models.BaseResponseDataModel
|
|
33
|
+
import com.assentify.sdk.RemoteClient.Models.KycDocumentDetails
|
|
34
|
+
import com.assentify.sdk.ScanIDCard.IDExtractedModel
|
|
35
|
+
import com.assentify.sdk.ScanPassport.ScanPassportResult
|
|
36
|
+
import com.assentify.sdk.ScanQr.ScanQrCallback
|
|
37
|
+
import com.assentify.sdk.ScanQr.ScanQr
|
|
38
|
+
import com.assentify.sdk.ScanQr.ScanQrManual
|
|
39
|
+
import com.assentify.sdk.ScanQr.ScanQrResult
|
|
40
|
+
import com.google.gson.reflect.TypeToken
|
|
41
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
42
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
43
|
+
import com.facebook.react.bridge.Arguments
|
|
44
|
+
import android.content.Context
|
|
45
|
+
import com.assentify.sdk.RemoteClient.Models.SubmitRequestModel
|
|
46
|
+
|
|
47
|
+
class QrActivity : AppCompatActivity() , ScanQrCallback {
|
|
48
|
+
private lateinit var language: String;
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
private lateinit var reactApplicationContext: ReactApplicationContext
|
|
52
|
+
private lateinit var assentifySdk: AssentifySdk
|
|
53
|
+
|
|
54
|
+
private lateinit var holdHandColor: String;
|
|
55
|
+
private lateinit var processingColor: String;
|
|
56
|
+
|
|
57
|
+
private lateinit var jsonStringKycDocumentDetails: String;
|
|
58
|
+
private lateinit var kycDocumentDetails: List<KycDocumentDetails>;
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
private lateinit var popUpContainer: LinearLayout
|
|
62
|
+
private lateinit var popUpIcon: ImageView
|
|
63
|
+
private lateinit var popUpText: TextView
|
|
64
|
+
private lateinit var popUpSubText: TextView
|
|
65
|
+
private lateinit var popUpButton: Button
|
|
66
|
+
private var start: Boolean = false;
|
|
67
|
+
|
|
68
|
+
private lateinit var scanQr: ScanQr
|
|
69
|
+
private lateinit var scanQrManual: ScanQrManual
|
|
70
|
+
private var stepID: Int = -1;
|
|
71
|
+
|
|
72
|
+
private var isManual: Boolean = false;
|
|
73
|
+
private lateinit var takePhotoButton: Button;
|
|
74
|
+
private lateinit var manualClickColor: String;
|
|
75
|
+
private lateinit var infoLayout: LinearLayout
|
|
76
|
+
private lateinit var infoText: TextView
|
|
77
|
+
private lateinit var infoIcon: ImageView
|
|
78
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
79
|
+
super.onCreate(savedInstanceState)
|
|
80
|
+
setContentView(R.layout.activity_qr)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
jsonStringKycDocumentDetails = intent.getStringExtra("kycDocumentDetails")!!
|
|
84
|
+
manualClickColor = intent.getStringExtra("manualClickColor")!!
|
|
85
|
+
val gson = Gson()
|
|
86
|
+
val listType = object : TypeToken<List<KycDocumentDetails>>() {}.type
|
|
87
|
+
kycDocumentDetails = gson.fromJson(jsonStringKycDocumentDetails, listType)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
reactApplicationContext = ReactApplicationContextObject.getReactApplicationContextObject()
|
|
91
|
+
language = intent.getStringExtra("language")!!
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
holdHandColor = intent.getStringExtra("holdHandColor")!!
|
|
95
|
+
processingColor = intent.getStringExtra("processingColor")!!
|
|
96
|
+
stepID = intent.getIntExtra("stepID",-1)
|
|
97
|
+
|
|
98
|
+
infoLayout = findViewById<LinearLayout>(R.id.infoLayout)
|
|
99
|
+
val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
|
|
100
|
+
drawableInfo?.setColorFilter(Color.parseColor(holdHandColor), PorterDuff.Mode.SRC_ATOP)
|
|
101
|
+
infoLayout.setBackground(drawableInfo)
|
|
102
|
+
infoLayout.visibility = View.GONE
|
|
103
|
+
infoText = findViewById(R.id.infoText)
|
|
104
|
+
infoText.setText("Please present ID")
|
|
105
|
+
infoText.setTextColor(Color.parseColor(processingColor))
|
|
106
|
+
|
|
107
|
+
infoIcon = findViewById<ImageView>(R.id.info_icon)
|
|
108
|
+
infoIcon.setImageDrawable(getResources().getDrawable(R.drawable.info_icon))
|
|
109
|
+
|
|
110
|
+
takePhotoButton = findViewById<Button>(R.id.takePhoto)
|
|
111
|
+
takePhotoButton.visibility = View.GONE
|
|
112
|
+
takePhotoButton.setTextColor(Color.parseColor(processingColor))
|
|
113
|
+
takePhotoButton.backgroundTintList = ColorStateList.valueOf(
|
|
114
|
+
Color.parseColor(manualClickColor)
|
|
115
|
+
)
|
|
116
|
+
takePhotoButton.setOnClickListener {
|
|
117
|
+
scanQrManual.takePicture();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
val backButton = findViewById<RelativeLayout>(R.id.backButton)
|
|
124
|
+
val backIcon = findViewById<ImageView>(R.id.back_icon)
|
|
125
|
+
val drawable = getResources().getDrawable(R.drawable.rounded_background)
|
|
126
|
+
drawable?.setColorFilter(Color.parseColor(holdHandColor), PorterDuff.Mode.SRC_ATOP)
|
|
127
|
+
backButton.setBackground(drawable)
|
|
128
|
+
backIcon.setColorFilter(Color.parseColor(processingColor));
|
|
129
|
+
|
|
130
|
+
val toolbarTitle = findViewById<TextView>(R.id.toolbar_title)
|
|
131
|
+
toolbarTitle.setText("Qr Capture")
|
|
132
|
+
toolbarTitle.setTextColor(Color.parseColor(processingColor))
|
|
133
|
+
|
|
134
|
+
backButton.setOnClickListener {
|
|
135
|
+
runOnUiThread {
|
|
136
|
+
triggerEvent("onBackClick", null)
|
|
137
|
+
if(isManual){
|
|
138
|
+
scanQrManual.closeCamera();
|
|
139
|
+
}else{
|
|
140
|
+
scanQr.closeCamera();
|
|
141
|
+
}
|
|
142
|
+
finish()
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
popUpContainer = findViewById<LinearLayout>(R.id.popUpContainer)
|
|
147
|
+
val drawablePopUpContainer = getResources().getDrawable(R.drawable.info_rounded_background)
|
|
148
|
+
drawablePopUpContainer?.setColorFilter(
|
|
149
|
+
Color.parseColor(holdHandColor),
|
|
150
|
+
PorterDuff.Mode.SRC_ATOP
|
|
151
|
+
)
|
|
152
|
+
popUpContainer.setBackground(drawablePopUpContainer)
|
|
153
|
+
popUpContainer.visibility = View.GONE
|
|
154
|
+
popUpContainer.setOnClickListener {
|
|
155
|
+
if (!start) {
|
|
156
|
+
popUpContainer.visibility = View.GONE
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
assentifySdk = AssentifySdkObject.getAssentifySdkObject();
|
|
161
|
+
startAssentifySdk()
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
fun showPopUpMessage(icon: Int, title: String, subTitle: String, isSending: Boolean) {
|
|
166
|
+
popUpContainer.visibility = View.VISIBLE
|
|
167
|
+
|
|
168
|
+
popUpIcon = findViewById<ImageView>(R.id.popUpIcon)
|
|
169
|
+
popUpIcon.setImageDrawable(getResources().getDrawable(icon))
|
|
170
|
+
popUpIcon.visibility = View.VISIBLE
|
|
171
|
+
|
|
172
|
+
popUpText = findViewById(R.id.popUpText)
|
|
173
|
+
popUpText.setText(title)
|
|
174
|
+
popUpText.setTextColor(Color.parseColor(processingColor))
|
|
175
|
+
|
|
176
|
+
popUpSubText = findViewById(R.id.popUpSubText)
|
|
177
|
+
popUpSubText.visibility = View.GONE
|
|
178
|
+
|
|
179
|
+
val drawablePopUpButton = getResources().getDrawable(R.drawable.button_rounded_background)
|
|
180
|
+
drawablePopUpButton?.setColorFilter(
|
|
181
|
+
Color.parseColor(processingColor),
|
|
182
|
+
PorterDuff.Mode.SRC_ATOP
|
|
183
|
+
)
|
|
184
|
+
popUpButton = findViewById(R.id.popUpButton)
|
|
185
|
+
popUpButton.setBackground(drawablePopUpButton)
|
|
186
|
+
popUpButton.setTextColor(Color.parseColor(holdHandColor))
|
|
187
|
+
|
|
188
|
+
popUpButton.setOnClickListener {
|
|
189
|
+
if (!start) {
|
|
190
|
+
popUpContainer.visibility = View.GONE
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (isSending) {
|
|
195
|
+
popUpButton.visibility = View.GONE
|
|
196
|
+
} else {
|
|
197
|
+
popUpButton.visibility = View.VISIBLE
|
|
198
|
+
}
|
|
199
|
+
if (subTitle.isNotEmpty()) {
|
|
200
|
+
popUpSubText.setText(subTitle)
|
|
201
|
+
popUpSubText.setTextColor(Color.parseColor(processingColor))
|
|
202
|
+
popUpSubText.visibility = View.VISIBLE
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
fun startAssentifySdk() {
|
|
209
|
+
assentifySdk = AssentifySdkObject.getAssentifySdkObject();
|
|
210
|
+
when (val result = assentifySdk!!.startScanQr(
|
|
211
|
+
this@QrActivity,
|
|
212
|
+
kycDocumentDetails,
|
|
213
|
+
language,
|
|
214
|
+
stepId = stepID,
|
|
215
|
+
)) {
|
|
216
|
+
is ScanQrResult.Manual -> {
|
|
217
|
+
isManual = true
|
|
218
|
+
runOnUiThread{
|
|
219
|
+
infoLayout.visibility = View.GONE
|
|
220
|
+
val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
|
|
221
|
+
drawableInfo?.setColorFilter(Color.parseColor(manualClickColor), PorterDuff.Mode.SRC_ATOP)
|
|
222
|
+
takePhotoButton.setBackground(drawableInfo)
|
|
223
|
+
takePhotoButton.visibility = View.VISIBLE
|
|
224
|
+
}
|
|
225
|
+
scanQrManual = result.data
|
|
226
|
+
Thread.sleep(500);
|
|
227
|
+
var fragmentManager = supportFragmentManager
|
|
228
|
+
var transaction = fragmentManager.beginTransaction()
|
|
229
|
+
transaction.replace(R.id.fragmentContainer, result.data)
|
|
230
|
+
transaction.commit()
|
|
231
|
+
}
|
|
232
|
+
is ScanQrResult.Auto -> {
|
|
233
|
+
scanQr = result.data
|
|
234
|
+
runOnUiThread{
|
|
235
|
+
infoLayout.visibility = View.VISIBLE
|
|
236
|
+
}
|
|
237
|
+
Thread.sleep(500);
|
|
238
|
+
var fragmentManager = supportFragmentManager
|
|
239
|
+
var transaction = fragmentManager.beginTransaction()
|
|
240
|
+
transaction.replace(R.id.fragmentContainer, result.data)
|
|
241
|
+
transaction.commit()
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
override fun onCompleteQrScan(dataModel: IDResponseModel) {
|
|
252
|
+
triggerCompleteEvent("onCompleteQrScan", dataModel.iDExtractedModel);
|
|
253
|
+
runOnUiThread {
|
|
254
|
+
/** Data To Submit **/
|
|
255
|
+
val documentCaptureSharedPreferences =
|
|
256
|
+
reactApplicationContext.getSharedPreferences("SubmitStepModel", Context.MODE_PRIVATE)
|
|
257
|
+
|
|
258
|
+
val stepKey = stepID.toString()
|
|
259
|
+
|
|
260
|
+
val editor = documentCaptureSharedPreferences.edit()
|
|
261
|
+
|
|
262
|
+
if (documentCaptureSharedPreferences.contains(stepKey)) {
|
|
263
|
+
editor.remove(stepKey)
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
val documentCaptureModel = SubmitRequestModel(
|
|
267
|
+
stepID,
|
|
268
|
+
StepsName.DocumentCapture,
|
|
269
|
+
convertMap(dataModel.iDExtractedModel!!.transformedProperties)
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
val documentCaptureStep = Gson().toJson(documentCaptureModel)
|
|
273
|
+
|
|
274
|
+
editor.putString(stepKey, documentCaptureStep)
|
|
275
|
+
editor.apply()
|
|
276
|
+
if(isManual){
|
|
277
|
+
scanQrManual.closeCamera();
|
|
278
|
+
}else{
|
|
279
|
+
scanQr.closeCamera();
|
|
280
|
+
}
|
|
281
|
+
finish()
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
override fun onErrorQrScan(message: String) {
|
|
286
|
+
runOnUiThread {
|
|
287
|
+
infoLayout.visibility = View.VISIBLE
|
|
288
|
+
start = false;
|
|
289
|
+
showPopUpMessage(R.drawable.warning, "Unable to Scan", "Let's try again", false)
|
|
290
|
+
}
|
|
291
|
+
triggerEvent("onErrorQrScan", null);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
override fun onStartQrScan() {
|
|
295
|
+
triggerEvent("onStartQrScan", null);
|
|
296
|
+
runOnUiThread {
|
|
297
|
+
infoLayout.visibility = View.GONE
|
|
298
|
+
start = true;
|
|
299
|
+
runOnUiThread {
|
|
300
|
+
showPopUpMessage(R.drawable.sending, "Transmitting", "", true)
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
private fun triggerCompleteEvent(eventName:String, dataModel: IDExtractedModel?){
|
|
306
|
+
val eventResultMap = Arguments.createMap().apply {
|
|
307
|
+
if(dataModel!=null){
|
|
308
|
+
val gson = Gson()
|
|
309
|
+
val jsonString = gson.toJson(dataModel!!)
|
|
310
|
+
putString("IdQrDataModel", jsonString)
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
314
|
+
.emit(eventName, eventResultMap)
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
}
|
|
318
|
+
private fun triggerEvent(eventName:String, dataModel: BaseResponseDataModel?){
|
|
319
|
+
val eventResultMap = Arguments.createMap().apply {
|
|
320
|
+
if(dataModel!=null){
|
|
321
|
+
putString("IdQrDataModel", dataModel.response)
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
325
|
+
.emit(eventName, eventResultMap)
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
override fun onPause() {
|
|
331
|
+
try {
|
|
332
|
+
if (::scanQr.isInitialized) {
|
|
333
|
+
if(isManual){
|
|
334
|
+
scanQrManual.closeCamera();
|
|
335
|
+
}else{
|
|
336
|
+
scanQr.closeCamera();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
} catch (e: Exception) {}
|
|
340
|
+
super.onPause()
|
|
341
|
+
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
override fun onDestroy() {
|
|
345
|
+
try {
|
|
346
|
+
if (::scanQr.isInitialized) {
|
|
347
|
+
if(isManual){
|
|
348
|
+
scanQrManual.closeCamera();
|
|
349
|
+
}else{
|
|
350
|
+
scanQr.closeCamera();
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
} catch (e: Exception) {}
|
|
354
|
+
super.onDestroy()
|
|
355
|
+
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
fun convertMap(map: Map<String, Any>?): Map<String, String> {
|
|
359
|
+
return map?.mapValues {
|
|
360
|
+
it.value.toString()
|
|
361
|
+
} ?: emptyMap()
|
|
362
|
+
}
|
|
363
|
+
}
|