assentify-sdk-react-native 0.0.33 → 0.0.35

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
@@ -93,6 +93,13 @@ yarn add assentify-sdk-react-native
93
93
 
94
94
  ## Versions
95
95
 
96
+ **0.0.35**
97
+ - Callbacks Improvements
98
+ - Captured Image Improvements
99
+
100
+ **0.0.34**
101
+ - Ability to split the front and back scanning of the IDs
102
+
96
103
  **0.0.33**
97
104
  - Manual Capture
98
105
  - Retry Logic
@@ -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.85'
102
+ implementation 'com.github.AssentifyLTD:Assentify.SDK.Android:0.0.86'
103
103
 
104
104
  /* Assentify Sdk Dependencies */
105
105
  implementation 'com.google.code.gson:gson:2.8.9'
@@ -325,25 +325,30 @@ class ScanIDActivity: AppCompatActivity(),
325
325
  }
326
326
  /** Data To Submit **/
327
327
 
328
- val documentCaptureSharedPreferences =
329
- reactApplicationContext.getSharedPreferences("SubmitStepModel", Context.MODE_PRIVATE)
330
-
331
- val stepKey = stepID.toString()
332
- val editor = documentCaptureSharedPreferences.edit()
328
+ val sharedPreferences = reactApplicationContext.getSharedPreferences("SubmitStepModel", Context.MODE_PRIVATE)
329
+ val gson = Gson()
330
+ val existingJson = sharedPreferences.getString(stepID.toString(), null)
331
+ val updatedModel: SubmitRequestModel = if (existingJson != null) {
332
+ // Deserialize to object
333
+ val existingModel = gson.fromJson(existingJson, SubmitRequestModel::class.java)
333
334
 
334
- if (documentCaptureSharedPreferences.contains(stepKey)) {
335
- editor.remove(stepKey)
336
- }
335
+ // Make a mutable copy of the existing map
336
+ val updatedInfo = existingModel.extractedInformation.toMutableMap()
337
337
 
338
- val documentCaptureModel = SubmitRequestModel(
339
- stepID!!,
340
- StepsName.DocumentCapture,
341
- values
342
- )
338
+ // Merge new values (replace if exists, add if not)
339
+ for ((k, v) in values) {
340
+ updatedInfo[k] = v
341
+ }
343
342
 
344
- val documentCaptureStep = Gson().toJson(documentCaptureModel)
345
- editor.putString(stepKey, documentCaptureStep)
346
- editor.apply()
343
+ // Create new model with updated map
344
+ existingModel.copy(extractedInformation = updatedInfo)
345
+ } else {
346
+ // If no existing model, just create a new one
347
+ SubmitRequestModel(stepID!!, StepsName.DocumentCapture, values)
348
+ }
349
+ sharedPreferences.edit()
350
+ .putString(stepID.toString(), gson.toJson(updatedModel))
351
+ .apply()
347
352
 
348
353
 
349
354
 
@@ -374,22 +379,30 @@ class ScanIDActivity: AppCompatActivity(),
374
379
  scanID.stopScanning();
375
380
  }
376
381
  /** Data To Submit **/
377
- val documentCaptureSharedPreferences = reactApplicationContext.getSharedPreferences("SubmitStepModel", Context.MODE_PRIVATE)
378
- val documentCaptureModel = SubmitRequestModel(
379
- stepID!!,StepsName.DocumentCapture,
380
- values
381
- );
382
- val documentCaptureSharedPreferencesEditor =
383
- documentCaptureSharedPreferences.edit()
384
- val documentCaptureGson = Gson()
385
- val documentCaptureStep: String =
386
- documentCaptureGson.toJson(documentCaptureModel)
387
- documentCaptureSharedPreferencesEditor.putString(
388
- stepID.toString(),
389
- documentCaptureStep
390
- );
391
- documentCaptureSharedPreferencesEditor.apply()
392
382
 
383
+ val sharedPreferences = reactApplicationContext.getSharedPreferences("SubmitStepModel", Context.MODE_PRIVATE)
384
+ val gson = Gson()
385
+ val existingJson = sharedPreferences.getString(stepID.toString(), null)
386
+ val updatedModel: SubmitRequestModel = if (existingJson != null) {
387
+ // Deserialize to object
388
+ val existingModel = gson.fromJson(existingJson, SubmitRequestModel::class.java)
389
+
390
+ // Make a mutable copy of the existing map
391
+ val updatedInfo = existingModel.extractedInformation.toMutableMap()
392
+
393
+ for ((k, v) in values) {
394
+ updatedInfo[k] = v
395
+ }
396
+
397
+ // Create new model with updated map
398
+ existingModel.copy(extractedInformation = updatedInfo)
399
+ } else {
400
+ // If no existing model, just create a new one
401
+ SubmitRequestModel(stepID!!, StepsName.DocumentCapture, values)
402
+ }
403
+ sharedPreferences.edit()
404
+ .putString(stepID.toString(), gson.toJson(updatedModel))
405
+ .apply()
393
406
 
394
407
  /** **/
395
408
  runOnUiThread {
@@ -277,6 +277,14 @@ class ScanPassportActivity : AppCompatActivity(),
277
277
  }
278
278
  }
279
279
 
280
+ override fun onWrongTemplate(dataModel: BaseResponseDataModel) {
281
+ triggerEvent("onWrongTemplate", dataModel);
282
+ runOnUiThread {
283
+ start = false;
284
+ showPopUpMessage(R.drawable.warning, "Please double-check that you selected the correct ID type and are presenting this ID type", "Let's try again", false)
285
+ }
286
+ }
287
+
280
288
  override fun onComplete(dataModel: PassportResponseModel,doneFlag: DoneFlags) {
281
289
 
282
290
  if (doneFlag == DoneFlags.Success && isExpired(dataModel.passportExtractedModel!!.identificationDocumentCapture!!.expiryDate.toString())) {
@@ -38,6 +38,6 @@ Pod::Spec.new do |s|
38
38
 
39
39
 
40
40
  s.dependency "React-Core"
41
- s.dependency "AssentifySdk", '0.0.70'
41
+ s.dependency "AssentifySdk", '0.0.71'
42
42
 
43
43
  end
@@ -2,6 +2,10 @@ import UIKit
2
2
  import AssentifySdk
3
3
 
4
4
  class PassportScannerView: UIView, ScanPassportDelegate {
5
+ func onWrongTemplate(dataModel: RemoteProcessingModel) {
6
+ //
7
+ }
8
+
5
9
  func onComplete(dataModel: PassportResponseModel, doneFlag: DoneFlags) {
6
10
 
7
11
  }
@@ -214,13 +214,8 @@ class IDCardController: UIViewController ,ScanIDCardDelegate , ChildViewControll
214
214
 
215
215
  if(order == self._kycDocumentDetails.count-1 ){
216
216
 
217
- if let outputProperties = try? JSONSerialization.data(withJSONObject: self.outputResultProperties, options: []) {
218
- if UserDefaults.standard.object(forKey: String(self.stepID)) != nil {
219
- UserDefaults.standard.removeObject(forKey: String(self.stepID))
220
- }
221
- UserDefaults.standard.set(nil, forKey:String(self.stepID))
222
- UserDefaults.standard.set(outputProperties, forKey: String(self.stepID))
223
- }
217
+ self.mergeAndStoreOutputProperties(stepID: self.stepID, newProperties: self.outputResultProperties ?? [:])
218
+
224
219
  DispatchQueue.main.async {
225
220
  self.scanID?.stopScanning()
226
221
  self.scanID?.willMove(toParent: nil)
@@ -446,6 +441,27 @@ class IDCardController: UIViewController ,ScanIDCardDelegate , ChildViewControll
446
441
  }
447
442
  }
448
443
 
444
+ func mergeAndStoreOutputProperties(stepID: Int, newProperties: [String: Any]) {
445
+ let key = String(stepID)
446
+
447
+ // Try to fetch old stored properties
448
+ var oldProperties: [String: Any] = [:]
449
+ if let data = UserDefaults.standard.data(forKey: key),
450
+ let storedDict = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
451
+ oldProperties = storedDict
452
+ }
453
+
454
+ // Merge: override existing keys, add new ones
455
+ var mergedProperties = oldProperties
456
+ for (k, v) in newProperties {
457
+ mergedProperties[k] = v
458
+ }
459
+
460
+ // Save back
461
+ if let mergedData = try? JSONSerialization.data(withJSONObject: mergedProperties, options: []) {
462
+ UserDefaults.standard.set(mergedData, forKey: key)
463
+ }
464
+ }
449
465
 
450
466
 
451
467
 
@@ -6,6 +6,8 @@ import AssentifySdk
6
6
 
7
7
  class PassportController: UIViewController ,ScanPassportDelegate , ChildViewControllerDelegate
8
8
  {
9
+
10
+
9
11
 
10
12
 
11
13
 
@@ -175,6 +177,15 @@ class PassportController: UIViewController ,ScanPassportDelegate , ChildViewCont
175
177
  self.popUpMessage = showPopUpMessage(view: self.view, title: "Please use your original physical ID card, not a photo or copy.", subTitle: "Please real ID (Not copy)",initialTextColorHex:self.processingColor,initialBackgroundColorHex:self.holdHandColor, iconName: "warning", isGif: false,target: self, action: #selector(self.dismissPopUpMessage))
176
178
  }
177
179
  }
180
+
181
+ func onWrongTemplate(dataModel:RemoteProcessingModel) {
182
+ triggerEvent(eventName:"onWrongTemplate",dataModel:dataModel)
183
+ DispatchQueue.main.async {
184
+ self.start = false;
185
+ self.popUpMessage!.removeFromSuperview();
186
+ self.popUpMessage = showPopUpMessage(view: self.view, title: "Please double-check that you selected the correct ID type and are presenting this ID type.", subTitle: "Let's try again",initialTextColorHex:self.processingColor,initialBackgroundColorHex:self.holdHandColor, iconName: "id_warning", isGif: false,target: self, action: #selector(self.dismissPopUpMessage))
187
+ }
188
+ }
178
189
 
179
190
  func onClipPreparationComplete(dataModel: RemoteProcessingModel) {
180
191
  triggerEvent(eventName:"onClipPreparationComplete",dataModel:dataModel)
@@ -191,7 +202,6 @@ class PassportController: UIViewController ,ScanPassportDelegate , ChildViewCont
191
202
 
192
203
 
193
204
  func onComplete(dataModel: PassportResponseModel,doneFlag:DoneFlags) {
194
- print("Passport onComplete: \(dataModel)")
195
205
 
196
206
 
197
207
  if let isExpired = dataModel.passportExtractedModel?
@@ -1 +1 @@
1
- {"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../../../example/src/Home.tsx"],"names":[],"mappings":"AACA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAsBnD,QAAA,MAAM,IAAI,yBA+QT,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../../../example/src/Home.tsx"],"names":[],"mappings":"AACA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAsBnD,QAAA,MAAM,IAAI,yBAwST,CAAC;AAEF,eAAe,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assentify-sdk-react-native",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "description": "This package provides integration with Assentify's services, allowing developers to incorporate Assentify functionalities seamlessly into their applications.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",