assentify-sdk-react-native 0.0.31 → 0.0.33

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.
Files changed (60) hide show
  1. package/README.md +8 -0
  2. package/android/build.gradle +3 -1
  3. package/android/src/main/java/com/assentifysdk/AssentifySdkModule.kt +26 -3
  4. package/android/src/main/java/com/assentifysdk/FaceMatchActivity.kt +78 -20
  5. package/android/src/main/java/com/assentifysdk/ScanIDActivity.kt +150 -36
  6. package/android/src/main/java/com/assentifysdk/ScanOtherActivity.kt +80 -19
  7. package/android/src/main/java/com/assentifysdk/ScanPassportActivity.kt +79 -23
  8. package/android/src/main/res/drawable/button_rounded_background.xml +4 -4
  9. package/android/src/main/res/layout/activity_face_scan.xml +234 -219
  10. package/android/src/main/res/layout/activity_scan.xml +116 -0
  11. package/assentify-sdk.podspec +1 -1
  12. package/ios/NativeAssentifySdk.mm +6 -0
  13. package/ios/NativeAssentifySdk.swift +24 -7
  14. package/ios/UIComponents/RNPassportScanner.swift +4 -0
  15. package/ios/View/FaceMatchController.swift +49 -8
  16. package/ios/View/IDCardController.swift +81 -18
  17. package/ios/View/OtherController.swift +49 -11
  18. package/ios/View/PassportController.swift +57 -13
  19. package/ios/View/UI.swift +192 -36
  20. package/lib/commonjs/AssentifyProvider.js +12 -4
  21. package/lib/commonjs/AssentifyProvider.js.map +1 -1
  22. package/lib/commonjs/AssentifyWrapper.js +2 -2
  23. package/lib/commonjs/AssentifyWrapper.js.map +1 -1
  24. package/lib/commonjs/DoneFlags.js +14 -0
  25. package/lib/commonjs/DoneFlags.js.map +1 -0
  26. package/lib/commonjs/index.js +12 -0
  27. package/lib/commonjs/index.js.map +1 -1
  28. package/lib/module/AssentifyProvider.js +12 -4
  29. package/lib/module/AssentifyProvider.js.map +1 -1
  30. package/lib/module/AssentifyWrapper.js +2 -2
  31. package/lib/module/AssentifyWrapper.js.map +1 -1
  32. package/lib/module/DoneFlags.js +8 -0
  33. package/lib/module/DoneFlags.js.map +1 -0
  34. package/lib/module/index.js +1 -0
  35. package/lib/module/index.js.map +1 -1
  36. package/lib/typescript/example/src/Home.d.ts.map +1 -1
  37. package/lib/typescript/lib/commonjs/AssentifyProvider.d.ts.map +1 -1
  38. package/lib/typescript/lib/commonjs/AssentifyWrapper.d.ts +1 -1
  39. package/lib/typescript/lib/commonjs/AssentifyWrapper.d.ts.map +1 -1
  40. package/lib/typescript/lib/commonjs/DoneFlags.d.ts +9 -0
  41. package/lib/typescript/lib/commonjs/DoneFlags.d.ts.map +1 -0
  42. package/lib/typescript/lib/module/AssentifyProvider.d.ts.map +1 -1
  43. package/lib/typescript/lib/module/AssentifyWrapper.d.ts +1 -1
  44. package/lib/typescript/lib/module/AssentifyWrapper.d.ts.map +1 -1
  45. package/lib/typescript/lib/module/DoneFlags.d.ts +8 -0
  46. package/lib/typescript/lib/module/DoneFlags.d.ts.map +1 -0
  47. package/lib/typescript/lib/module/index.d.ts +2 -1
  48. package/lib/typescript/lib/module/index.d.ts.map +1 -1
  49. package/lib/typescript/src/AssentifyProvider.d.ts.map +1 -1
  50. package/lib/typescript/src/AssentifyWrapper.d.ts +1 -1
  51. package/lib/typescript/src/AssentifyWrapper.d.ts.map +1 -1
  52. package/lib/typescript/src/DoneFlags.d.ts +9 -0
  53. package/lib/typescript/src/DoneFlags.d.ts.map +1 -0
  54. package/lib/typescript/src/index.d.ts +2 -1
  55. package/lib/typescript/src/index.d.ts.map +1 -1
  56. package/package.json +1 -1
  57. package/src/AssentifyProvider.tsx +11 -4
  58. package/src/AssentifyWrapper.ts +13 -1
  59. package/src/DoneFlags.ts +11 -0
  60. package/src/index.ts +1 -0
package/README.md CHANGED
@@ -93,6 +93,14 @@ yarn add assentify-sdk-react-native
93
93
 
94
94
  ## Versions
95
95
 
96
+ **0.0.33**
97
+ - Manual Capture
98
+ - Retry Logic
99
+ - Support Low Capabilities Devices
100
+
101
+ **0.0.32**
102
+ - Face match improvements
103
+
96
104
  **0.0.31**
97
105
  - Bug fixes
98
106
 
@@ -99,13 +99,15 @@ 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.83'
102
+ implementation 'com.github.AssentifyLTD:Assentify.SDK.Android:0.0.85'
103
103
 
104
104
  /* Assentify Sdk Dependencies */
105
105
  implementation 'com.google.code.gson:gson:2.8.9'
106
106
  implementation 'androidx.navigation:navigation-fragment-ktx:2.7.5'
107
107
  implementation 'androidx.navigation:navigation-ui-ktx:2.7.5'
108
108
  implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.17'
109
+ implementation 'com.squareup.picasso:picasso:2.71828'
110
+
109
111
 
110
112
  }
111
113
 
@@ -47,6 +47,7 @@ class AssentifySdkModule(context: ReactApplicationContext) :
47
47
  private lateinit var assentifySdk: AssentifySdk
48
48
  private lateinit var timeStarted: String
49
49
  private lateinit var apiKey: String
50
+ private lateinit var manualClickColor: String
50
51
  private lateinit var configModel: ConfigModel
51
52
  private val mainHandler = Handler(Looper.getMainLooper())
52
53
  private lateinit var environmentalConditions: EnvironmentalConditions
@@ -78,7 +79,13 @@ class AssentifySdkModule(context: ReactApplicationContext) :
78
79
  iOSBrightnessHighThreshold:Int = 255,
79
80
  iOSBrightnessLowThreshold:Int = 50,
80
81
  activeLiveType : String = "NONE",
81
- activeLivenessCheckCount:Int = 0
82
+ activeLivenessCheckCount:Int = 0,
83
+ retryCount:Int = 3,
84
+ faceLivenessRetryCount:Int = 2,
85
+ minRam:Int = 8,
86
+ iOSMinRam:Int = 2,
87
+ minCPUCores:Int = 6,
88
+ manualClickColor: String? = null
82
89
 
83
90
  ) {
84
91
  try {
@@ -91,6 +98,7 @@ class AssentifySdkModule(context: ReactApplicationContext) :
91
98
  }
92
99
 
93
100
  this.apiKey = apiKey
101
+ this.manualClickColor = manualClickColor!!
94
102
  val tag = "[ASSENTIFY INIT]"
95
103
 
96
104
  println("$tag ==============================================")
@@ -117,6 +125,12 @@ class AssentifySdkModule(context: ReactApplicationContext) :
117
125
  println("$tag iOSBrightnessLowThreshold: $iOSBrightnessLowThreshold")
118
126
  println("$tag ActiveLiveType: $activeLiveType")
119
127
  println("$tag ActiveLivenessCheckCount: $activeLivenessCheckCount")
128
+ println("$tag RetryCount: $retryCount")
129
+ println("$tag FaceLivenessRetryCount: $faceLivenessRetryCount")
130
+ println("$tag MinRam: $minRam")
131
+ println("$tag iOSMinRam: $iOSMinRam")
132
+ println("$tag MinCPUCores: $minCPUCores")
133
+ println("$tag ManualClickColor: $manualClickColor")
120
134
  println("$tag ==============================================")
121
135
 
122
136
  val typeActive: ActiveLiveType = when (activeLiveType) {
@@ -138,7 +152,11 @@ class AssentifySdkModule(context: ReactApplicationContext) :
138
152
  BRIGHTNESS_HIGH_THRESHOLD = androidBrightnessHighThreshold,
139
153
  BRIGHTNESS_LOW_THRESHOLD = androidBrightnessLowThreshold,
140
154
  activeLiveType = typeActive,
141
- activeLivenessCheckCount = activeLivenessCheckCount
155
+ activeLivenessCheckCount = activeLivenessCheckCount,
156
+ retryCount = retryCount,
157
+ faceLivenessRetryCount = faceLivenessRetryCount ,
158
+ minRam = minRam,
159
+ minCPUCores = minCPUCores
142
160
  )
143
161
 
144
162
  val eventResultMap = Arguments.createMap().apply {
@@ -164,7 +182,8 @@ class AssentifySdkModule(context: ReactApplicationContext) :
164
182
  performLivenessFace,
165
183
  storeImageStream,
166
184
  saveCapturedVideoID,
167
- saveCapturedVideoFace
185
+ saveCapturedVideoFace,
186
+ context = reactApplicationContext
168
187
  )
169
188
  } catch (e: Exception) {
170
189
  Log.e(NAME, e.toString())
@@ -184,6 +203,7 @@ class AssentifySdkModule(context: ReactApplicationContext) :
184
203
  intent.putExtra("showCountDown", true)
185
204
  intent.putExtra("apiKey", this.apiKey)
186
205
  intent.putExtra("stepID", stepID)
206
+ intent.putExtra("manualClickColor", this.manualClickColor)
187
207
  reactApplicationContext?.startActivity(intent)
188
208
  }
189
209
  }
@@ -200,6 +220,7 @@ class AssentifySdkModule(context: ReactApplicationContext) :
200
220
  intent.putExtra("showCountDown", true)
201
221
  intent.putExtra("apiKey", this.apiKey)
202
222
  intent.putExtra("stepID", stepID)
223
+ intent.putExtra("manualClickColor", this.manualClickColor)
203
224
  currentActivity?.startActivity(intent)
204
225
  }
205
226
 
@@ -224,6 +245,7 @@ class AssentifySdkModule(context: ReactApplicationContext) :
224
245
  intent.putExtra("showCountDown", true)
225
246
  intent.putExtra("apiKey", this.apiKey)
226
247
  intent.putExtra("stepID", stepID)
248
+ intent.putExtra("manualClickColor", this.manualClickColor)
227
249
  currentActivity?.startActivity(intent)
228
250
  } catch (e: Exception) {
229
251
  Log.e(NAME, e.toString())
@@ -247,6 +269,7 @@ class AssentifySdkModule(context: ReactApplicationContext) :
247
269
  intent.putExtra("processingColor", environmentalConditions.CustomColor)
248
270
  intent.putExtra("showCountDown", showCountDown)
249
271
  intent.putExtra("stepID", stepID)
272
+ intent.putExtra("manualClickColor", this.manualClickColor)
250
273
  currentActivity?.startActivity(intent)
251
274
  }
252
275
 
@@ -29,12 +29,17 @@ import pl.droidsonroids.gif.GifImageView
29
29
  import com.assentify.sdk.RemoteClient.Models.SubmitRequestModel
30
30
  import android.content.Context
31
31
  import android.content.Intent
32
+ import android.content.res.ColorStateList
33
+ import android.util.Log
32
34
  import com.facebook.react.modules.core.DeviceEventManagerModule
33
35
  import com.facebook.react.bridge.Arguments
34
36
  import com.facebook.react.bridge.ReactApplicationContext
35
37
  import com.assentify.sdk.Core.Constants.BrightnessEvents
36
38
  import com.assentify.sdk.Core.Constants.FaceEvents
37
39
  import com.assentify.sdk.Core.Constants.ActiveLiveEvents
40
+ import com.assentify.sdk.Core.Constants.DoneFlags
41
+ import com.assentify.sdk.FaceMatch.FaceMatchManual
42
+ import com.assentify.sdk.FaceMatch.FaceMatchResult
38
43
 
39
44
  class FaceMatchActivity: AppCompatActivity(),
40
45
  FaceMatchCallback {
@@ -42,6 +47,9 @@ class FaceMatchActivity: AppCompatActivity(),
42
47
  private lateinit var assentifySdk: AssentifySdk
43
48
  private lateinit var reactApplicationContext: ReactApplicationContext
44
49
  private lateinit var faceMatch: FaceMatch
50
+ private lateinit var faceMatchManual: FaceMatchManual
51
+ private var isManual: Boolean = false;
52
+
45
53
  private lateinit var infoText: TextView
46
54
  private lateinit var infoIcon: ImageView
47
55
  private lateinit var infoLayout: LinearLayout
@@ -56,8 +64,9 @@ private lateinit var assentifySdk: AssentifySdk
56
64
  private var showCountDown: Boolean = true;
57
65
  private var start: Boolean = false;
58
66
  private var stepID: Int = -1;
67
+ private lateinit var manualClickColor: String;
59
68
  private var currentActiveLiveEvents: ActiveLiveEvents = ActiveLiveEvents.Good
60
-
69
+ private lateinit var takePhotoButton: Button;
61
70
 
62
71
  override fun onCreate(savedInstanceState: Bundle?) {
63
72
  super.onCreate(savedInstanceState)
@@ -67,8 +76,24 @@ private lateinit var assentifySdk: AssentifySdk
67
76
  showCountDown = intent.getBooleanExtra("showCountDown",true)
68
77
  holdHandColor = intent.getStringExtra("holdHandColor")!!
69
78
  processingColor = intent.getStringExtra("processingColor")!!
79
+ manualClickColor = intent.getStringExtra("manualClickColor")!!
70
80
  stepID = intent.getIntExtra("stepID",-1)!!
71
81
 
82
+ takePhotoButton = findViewById<Button>(R.id.takePhoto)
83
+ takePhotoButton.visibility = View.GONE
84
+ takePhotoButton.setTextColor(Color.parseColor(processingColor))
85
+ takePhotoButton.backgroundTintList = ColorStateList.valueOf(
86
+ Color.parseColor(manualClickColor)
87
+ )
88
+ takePhotoButton.setOnClickListener {
89
+ faceMatchManual.takePicture();
90
+ }
91
+
92
+ infoLayout = findViewById<LinearLayout>(R.id.infoLayout)
93
+ val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
94
+ drawableInfo?.setColorFilter(Color.parseColor(holdHandColor), PorterDuff.Mode.SRC_ATOP)
95
+ infoLayout.setBackground(drawableInfo)
96
+
72
97
  startAssentifySdk()
73
98
 
74
99
  val backButton = findViewById<RelativeLayout>(R.id.backButton)
@@ -79,16 +104,17 @@ private lateinit var assentifySdk: AssentifySdk
79
104
  backButton.setOnClickListener {
80
105
  runOnUiThread {
81
106
  triggerEvent("onBackClick", null)
82
- faceMatch.stopScanning();
107
+ if(isManual){
108
+ faceMatchManual.stopScanning();
109
+ }else{
110
+ faceMatch.stopScanning();
111
+ }
83
112
  finish()
84
113
  }
85
114
  }
86
115
 
87
116
 
88
- infoLayout = findViewById<LinearLayout>(R.id.infoLayout)
89
- val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
90
- drawableInfo?.setColorFilter(Color.parseColor(holdHandColor), PorterDuff.Mode.SRC_ATOP)
91
- infoLayout.setBackground(drawableInfo)
117
+
92
118
 
93
119
 
94
120
  val toolbarTitle = findViewById<TextView>(R.id.toolbar_title)
@@ -119,11 +145,17 @@ private lateinit var assentifySdk: AssentifySdk
119
145
  }
120
146
  }
121
147
 
148
+
149
+
122
150
  }
123
151
 
124
152
  override fun onBackPressed() {
125
153
  triggerEvent("onBackClick", null)
126
- faceMatch.stopScanning();
154
+ if(isManual){
155
+ faceMatchManual.stopScanning();
156
+ }else{
157
+ faceMatch.stopScanning();
158
+ }
127
159
  finish()
128
160
  super.onBackPressed()
129
161
  }
@@ -177,23 +209,44 @@ private lateinit var assentifySdk: AssentifySdk
177
209
  val sharedPreferences = reactApplicationContext.getSharedPreferences("FaceMatch", Context.MODE_PRIVATE)
178
210
  val base64SecondImage = sharedPreferences.getString("Base64SecondImage", "")
179
211
  assentifySdk = AssentifySdkObject.getAssentifySdkObject();
180
- faceMatch = assentifySdk!!.startFaceMatch(
212
+
213
+ when (val result = assentifySdk!!.startFaceMatch(
181
214
  this@FaceMatchActivity,
182
215
  base64SecondImage!!,
183
216
  showCountDown,stepID!!
184
- );
185
- Thread.sleep(500);
186
- var fragmentManager = supportFragmentManager
187
- var transaction = fragmentManager.beginTransaction()
188
- transaction.replace(R.id.fragmentContainer, faceMatch)
189
- transaction.commit()
217
+ )) {
218
+ is FaceMatchResult.Manual -> {
219
+ faceMatchManual = result.data
220
+ isManual =true
221
+ runOnUiThread{
222
+ infoLayout.visibility = View.GONE
223
+ val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
224
+ drawableInfo?.setColorFilter(Color.parseColor(manualClickColor), PorterDuff.Mode.SRC_ATOP)
225
+ takePhotoButton.setBackground(drawableInfo)
226
+ takePhotoButton.visibility = View.VISIBLE
227
+ }
228
+ Thread.sleep(500);
229
+ var fragmentManager = supportFragmentManager
230
+ var transaction = fragmentManager.beginTransaction()
231
+ transaction.replace(R.id.fragmentContainer, result.data)
232
+ transaction.commit()
233
+ }
234
+ is FaceMatchResult.Auto -> {
235
+ faceMatch = result.data
236
+ Thread.sleep(500);
237
+ var fragmentManager = supportFragmentManager
238
+ var transaction = fragmentManager.beginTransaction()
239
+ transaction.replace(R.id.fragmentContainer, result.data)
240
+ transaction.commit()
241
+ }
242
+ }
190
243
  }
191
244
 
192
245
  override fun onError(dataModel: BaseResponseDataModel) {
193
246
  triggerEvent("onError", dataModel)
194
247
  runOnUiThread {
195
248
  start = false;
196
- showPopUpMessage(R.drawable.warning, "Please check your Wi-Fi or mobile data connection", "Let's try again", false)
249
+ showPopUpMessage(R.drawable.warning, "Your internet connection seems unstable. Please check your connection and try again.\n", "Let's try again", false)
197
250
  }
198
251
  }
199
252
 
@@ -219,12 +272,12 @@ private lateinit var assentifySdk: AssentifySdk
219
272
  triggerEvent("onLivenessUpdate", dataModel)
220
273
  runOnUiThread {
221
274
  start = false;
222
- showPopUpMessage(R.drawable.warning, "Liveness Failed", "", false)
275
+ showPopUpMessage(R.drawable.warning, "Please make sure your face is well lit, look directly at the camera, and avoid using photos or videos. Try again", "", false)
223
276
  }
224
277
  }
225
278
 
226
- override fun onComplete(dataModel: FaceResponseModel) {
227
- triggerCompleteEvent("onComplete",dataModel)
279
+ override fun onComplete(dataModel: FaceResponseModel,doneFlag: DoneFlags) {
280
+ triggerCompleteEvent("onComplete",dataModel,doneFlag)
228
281
  /** Data To Submit **/
229
282
  val documentCaptureSharedPreferences =
230
283
  reactApplicationContext.getSharedPreferences("SubmitStepModel", Context.MODE_PRIVATE)
@@ -249,7 +302,11 @@ private lateinit var assentifySdk: AssentifySdk
249
302
 
250
303
  runOnUiThread{
251
304
  start = false
252
- faceMatch.stopScanning();
305
+ if(isManual){
306
+ faceMatchManual.stopScanning();
307
+ }else{
308
+ faceMatch.stopScanning();
309
+ }
253
310
  finish()
254
311
  }
255
312
  }
@@ -350,12 +407,13 @@ private lateinit var assentifySdk: AssentifySdk
350
407
  }
351
408
 
352
409
 
353
- private fun triggerCompleteEvent(eventName:String, dataModel: FaceResponseModel?){
410
+ private fun triggerCompleteEvent(eventName:String, dataModel: FaceResponseModel?,doneFlag: DoneFlags){
354
411
  val eventResultMap = Arguments.createMap().apply {
355
412
  if(dataModel!=null){
356
413
  val gson = Gson()
357
414
  val jsonString = gson.toJson(dataModel.faceExtractedModel!!)
358
415
  putString("FaceMatchDataModel", jsonString)
416
+ putString("DoneFlag", doneFlag.toString())
359
417
  }
360
418
  }
361
419
  reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
@@ -31,10 +31,15 @@ import com.assentify.sdk.RemoteClient.Models.StepDefinitions
31
31
  import com.assentify.sdk.RemoteClient.Models.StepMap
32
32
  import ImageToBase64Converter
33
33
  import android.content.Intent
34
+ import android.content.res.ColorStateList
34
35
  import com.assentify.sdk.Core.Constants.BrightnessEvents
36
+ import com.assentify.sdk.Core.Constants.DoneFlags
35
37
  import com.assentify.sdk.RemoteClient.Models.SubmitRequestModel
38
+ import com.assentify.sdk.ScanIDCard.ScanIDCardManual
39
+ import com.assentify.sdk.ScanIDCard.ScanIDCardResult
36
40
  import com.facebook.react.bridge.Arguments
37
41
  import com.facebook.react.modules.core.DeviceEventManagerModule
42
+ import com.squareup.picasso.Picasso
38
43
 
39
44
  class ScanIDActivity: AppCompatActivity(),
40
45
  IDCardCallback {
@@ -43,6 +48,8 @@ class ScanIDActivity: AppCompatActivity(),
43
48
  private lateinit var reactApplicationContext: ReactApplicationContext
44
49
  private lateinit var assentifySdk: AssentifySdk
45
50
  private lateinit var scanID: ScanIDCard
51
+ private lateinit var scanIDManual: ScanIDCardManual
52
+ private var isManual: Boolean = false;
46
53
  private lateinit var infoText: TextView
47
54
  private lateinit var infoIcon: ImageView
48
55
  private lateinit var infoLayout: LinearLayout
@@ -66,6 +73,8 @@ class ScanIDActivity: AppCompatActivity(),
66
73
  private var apiKey: String = "";
67
74
  val values: MutableMap<String, String> = mutableMapOf()
68
75
  private var stepID: Int = -1;
76
+ private lateinit var takePhotoButton: Button;
77
+ private lateinit var manualClickColor: String;
69
78
  override fun onCreate(savedInstanceState: Bundle?) {
70
79
  super.onCreate(savedInstanceState)
71
80
  setContentView(R.layout.activity_scan)
@@ -83,7 +92,28 @@ class ScanIDActivity: AppCompatActivity(),
83
92
  isFlippingCard = intent.getBooleanExtra("flippingCard",false)!!
84
93
  showCountDown = intent.getBooleanExtra("showCountDown",true)
85
94
  apiKey = intent.getStringExtra("apiKey")!!
95
+ manualClickColor = intent.getStringExtra("manualClickColor")!!
86
96
  stepID = intent.getIntExtra("stepID",-1)!!
97
+
98
+ takePhotoButton = findViewById<Button>(R.id.takePhoto)
99
+ takePhotoButton.visibility = View.GONE
100
+ takePhotoButton.setTextColor(Color.parseColor(processingColor))
101
+ takePhotoButton.backgroundTintList = ColorStateList.valueOf(
102
+ Color.parseColor(manualClickColor)
103
+ )
104
+ takePhotoButton.setOnClickListener {
105
+ scanIDManual.takePicture();
106
+ }
107
+
108
+ infoLayout = findViewById<LinearLayout>(R.id.infoLayout)
109
+ val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
110
+ drawableInfo?.setColorFilter(Color.parseColor(holdHandColor), PorterDuff.Mode.SRC_ATOP)
111
+ infoLayout.setBackground(drawableInfo)
112
+
113
+ val toolbarTitle = findViewById<TextView>(R.id.toolbar_title)
114
+ toolbarTitle.setText(title)
115
+ toolbarTitle.setTextColor(Color.parseColor(processingColor))
116
+
87
117
  startAssentifySdk()
88
118
 
89
119
 
@@ -96,24 +126,24 @@ class ScanIDActivity: AppCompatActivity(),
96
126
  backButton.setOnClickListener {
97
127
  runOnUiThread {
98
128
  triggerEvent("onBackClick", null)
99
- scanID.stopScanning();
129
+ if(isManual){
130
+ scanIDManual.stopScanning();
131
+ }else{
132
+ scanID.stopScanning();
133
+ }
134
+
100
135
  finish()
101
136
  }
102
137
  }
103
138
 
104
139
 
105
- infoLayout = findViewById<LinearLayout>(R.id.infoLayout)
106
- val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
107
- drawableInfo?.setColorFilter(Color.parseColor(holdHandColor), PorterDuff.Mode.SRC_ATOP)
108
- infoLayout.setBackground(drawableInfo)
140
+
109
141
 
110
142
 
111
143
  flippingCard = findViewById<GifImageView>(R.id.flippingCard)
112
144
  flippingCard.visibility = View.GONE
113
145
 
114
- val toolbarTitle = findViewById<TextView>(R.id.toolbar_title)
115
- toolbarTitle.setText(title)
116
- toolbarTitle.setTextColor(Color.parseColor(processingColor))
146
+
117
147
 
118
148
 
119
149
  infoText = findViewById(R.id.infoText)
@@ -138,11 +168,17 @@ class ScanIDActivity: AppCompatActivity(),
138
168
  popUpContainer.visibility = View.GONE
139
169
  }
140
170
  }
171
+
172
+
141
173
  }
142
174
 
143
175
  override fun onBackPressed() {
144
176
  triggerEvent("onBackClick", null)
145
- scanID.stopScanning();
177
+ if(isManual){
178
+ scanIDManual.stopScanning();
179
+ }else{
180
+ scanID.stopScanning();
181
+ }
146
182
  finish()
147
183
  super.onBackPressed()
148
184
  }
@@ -199,14 +235,36 @@ class ScanIDActivity: AppCompatActivity(),
199
235
 
200
236
  fun startAssentifySdk() {
201
237
  assentifySdk = AssentifySdkObject.getAssentifySdkObject();
202
- scanID = assentifySdk!!.startScanIDCard(
238
+
239
+ when (val result = assentifySdk!!.startScanIDCard(
203
240
  this@ScanIDActivity,kycDocumentDetails,language,stepID!!
204
- );
205
- Thread.sleep(500);
206
- var fragmentManager = supportFragmentManager
207
- var transaction = fragmentManager.beginTransaction()
208
- transaction.replace(R.id.fragmentContainer, scanID)
209
- transaction.commit()
241
+ )) {
242
+ is ScanIDCardResult.Manual -> {
243
+ scanIDManual = result.data
244
+ isManual =true
245
+ runOnUiThread{
246
+ infoLayout.visibility = View.GONE
247
+ val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
248
+ drawableInfo?.setColorFilter(Color.parseColor(manualClickColor), PorterDuff.Mode.SRC_ATOP)
249
+ takePhotoButton.setBackground(drawableInfo)
250
+ takePhotoButton.visibility = View.VISIBLE
251
+ }
252
+ Thread.sleep(500);
253
+ var fragmentManager = supportFragmentManager
254
+ var transaction = fragmentManager.beginTransaction()
255
+ transaction.replace(R.id.fragmentContainer, result.data)
256
+ transaction.commit()
257
+ }
258
+ is ScanIDCardResult.Auto -> {
259
+ scanID = result.data
260
+ Thread.sleep(500);
261
+ var fragmentManager = supportFragmentManager
262
+ var transaction = fragmentManager.beginTransaction()
263
+ transaction.replace(R.id.fragmentContainer, result.data)
264
+ transaction.commit()
265
+ }
266
+ }
267
+
210
268
 
211
269
  }
212
270
 
@@ -214,7 +272,7 @@ class ScanIDActivity: AppCompatActivity(),
214
272
  triggerEvent("onError", dataModel)
215
273
  runOnUiThread {
216
274
  start = false;
217
- showPopUpMessage(R.drawable.warning, "Unable to extract", "Let's try again", false)
275
+ showPopUpMessage(R.drawable.warning, "Your internet connection seems unstable. Please check your connection and try again.\n", "Let's try again", false)
218
276
  }
219
277
  }
220
278
 
@@ -232,7 +290,7 @@ class ScanIDActivity: AppCompatActivity(),
232
290
  triggerEvent("onRetry", dataModel)
233
291
  runOnUiThread {
234
292
  start = false;
235
- showPopUpMessage(R.drawable.warning, "Unable to extract", "Let's try again", false)
293
+ showPopUpMessage(R.drawable.warning, "We couldn’t read your card. Try again in better lighting and make sure the card is clear and visible.", "Let's try again", false)
236
294
  }
237
295
  }
238
296
 
@@ -243,7 +301,7 @@ class ScanIDActivity: AppCompatActivity(),
243
301
  start = false;
244
302
  showPopUpMessage(
245
303
  R.drawable.id_warning,
246
- "Failed ID Check",
304
+ "Please use your original physical ID card, not a photo or copy.",
247
305
  "Please real ID (Not copy)",
248
306
  false
249
307
  )
@@ -251,16 +309,20 @@ class ScanIDActivity: AppCompatActivity(),
251
309
  }
252
310
 
253
311
 
254
- override fun onComplete(dataModel: IDResponseModel, order: Int) {
312
+ override fun onComplete(dataModel: IDResponseModel, order: Int,doneFlag:DoneFlags) {
255
313
 
256
- triggerCompleteEvent("onComplete",dataModel.iDExtractedModel!!)
314
+ triggerCompleteEvent("onComplete",dataModel.iDExtractedModel!!,doneFlag)
257
315
 
258
316
  values.putAll(convertMap(dataModel.iDExtractedModel!!.transformedProperties))
259
317
 
260
318
 
261
319
  if(kycDocumentDetails.size > 1){
262
320
  if(order == kycDocumentDetails.size -1 ){
263
- scanID.stopScanning();
321
+ if(isManual){
322
+ scanIDManual.stopScanning();
323
+ }else{
324
+ scanID.stopScanning();
325
+ }
264
326
  /** Data To Submit **/
265
327
 
266
328
  val documentCaptureSharedPreferences =
@@ -296,22 +358,21 @@ class ScanIDActivity: AppCompatActivity(),
296
358
  }
297
359
  hidePopUpMessage()
298
360
  if(isFlippingCard){
299
- flippingCard.visibility = View.VISIBLE
300
- val backgroundThread = Thread {
301
- try {
302
- Thread.sleep(5000)
303
- runOnUiThread{
304
- flippingCard.visibility = View.GONE
305
- }
306
- } catch (e: InterruptedException) {
307
- e.printStackTrace()
308
- }
361
+ showBackIDPage();
362
+ }else{
363
+ if(isManual){
364
+ scanIDManual.changeTemplateId(kycDocumentDetails.last().templateProcessingKeyInformation);
365
+ }else{
366
+ scanID.changeTemplateId(kycDocumentDetails.last().templateProcessingKeyInformation);
309
367
  }
310
- backgroundThread.start()
311
368
  }
312
369
  }
313
370
  }else{
314
- scanID.stopScanning();
371
+ if(isManual){
372
+ scanIDManual.stopScanning();
373
+ }else{
374
+ scanID.stopScanning();
375
+ }
315
376
  /** Data To Submit **/
316
377
  val documentCaptureSharedPreferences = reactApplicationContext.getSharedPreferences("SubmitStepModel", Context.MODE_PRIVATE)
317
378
  val documentCaptureModel = SubmitRequestModel(
@@ -343,7 +404,7 @@ class ScanIDActivity: AppCompatActivity(),
343
404
  triggerEvent("onWrongTemplate", dataModel);
344
405
  runOnUiThread {
345
406
  start = false;
346
- showPopUpMessage(R.drawable.warning, "Wrong Template", "Let's try again", false)
407
+ 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)
347
408
  }
348
409
  }
349
410
 
@@ -400,12 +461,13 @@ class ScanIDActivity: AppCompatActivity(),
400
461
  }
401
462
 
402
463
 
403
- private fun triggerCompleteEvent(eventName:String, dataModel: IDExtractedModel?){
464
+ private fun triggerCompleteEvent(eventName:String, dataModel: IDExtractedModel?,doneFlag:DoneFlags){
404
465
  val eventResultMap = Arguments.createMap().apply {
405
466
  if(dataModel!=null){
406
467
  val gson = Gson()
407
468
  val jsonString = gson.toJson(dataModel!!)
408
469
  putString("IdDataModel", jsonString)
470
+ putString("DoneFlag", doneFlag.toString())
409
471
  }
410
472
  }
411
473
  reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
@@ -444,4 +506,56 @@ class ScanIDActivity: AppCompatActivity(),
444
506
  }
445
507
 
446
508
 
509
+ fun showBackIDPage(){
510
+ runOnUiThread{
511
+
512
+ takePhotoButton.visibility = View.GONE
513
+ val toolbarTitle = findViewById<TextView>(R.id.toolbar_title)
514
+ toolbarTitle.setText("Capture Back of ID")
515
+ toolbarTitle.setTextColor(Color.parseColor(processingColor))
516
+
517
+
518
+ val backIDPage = findViewById<LinearLayout>(R.id.backIDPage)
519
+ backIDPage.setBackgroundColor(Color.parseColor(holdHandColor))
520
+ backIDPage.visibility = View.VISIBLE
521
+
522
+
523
+ val nextTemplate = findViewById<Button>(R.id.nextTemplate)
524
+ nextTemplate.setOnClickListener {
525
+ if(isManual){
526
+ scanIDManual.changeTemplateId(kycDocumentDetails.last().templateProcessingKeyInformation);
527
+ }else{
528
+ scanID.changeTemplateId(kycDocumentDetails.last().templateProcessingKeyInformation);
529
+ }
530
+ hidrBackIDPage();
531
+ }
532
+
533
+ val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
534
+ drawableInfo?.setColorFilter(Color.parseColor(manualClickColor), PorterDuff.Mode.SRC_ATOP)
535
+ nextTemplate.setBackground(drawableInfo)
536
+
537
+ val ivSample = findViewById<ImageView>(R.id.ivSample)
538
+ Picasso.get()
539
+ .load(kycDocumentDetails.last().templateSpecimen)
540
+ .into(ivSample)
541
+ }
542
+ }
543
+
544
+ fun hidrBackIDPage(){
545
+ runOnUiThread{
546
+ if(isManual){
547
+ takePhotoButton.visibility = View.VISIBLE
548
+ }
549
+ val toolbarTitle = findViewById<TextView>(R.id.toolbar_title)
550
+ toolbarTitle.setText(title)
551
+ toolbarTitle.setTextColor(Color.parseColor(processingColor))
552
+
553
+ val backIDPage = findViewById<LinearLayout>(R.id.backIDPage)
554
+ backIDPage.setBackgroundColor(Color.parseColor(holdHandColor))
555
+ backIDPage.visibility = View.GONE
556
+
557
+
558
+ }
559
+ }
560
+
447
561
  }