assentify-sdk-react-native 0.0.33 → 0.0.34

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
@@ -92,6 +92,8 @@ yarn add assentify-sdk-react-native
92
92
  ```
93
93
 
94
94
  ## Versions
95
+ **0.0.34**
96
+ - Ability to split the front and back scanning of the IDs
95
97
 
96
98
  **0.0.33**
97
99
  - Manual Capture
@@ -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 {
@@ -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
 
@@ -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,yBAqST,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.34",
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",