@@ -120,16 +120,20 @@ class IdscanSdkModule(reactContext: ReactApplicationContext) :
120120 fun scan (type : String? , apiKeys : ReadableMap , callback : Callback ) {
121121 Log .d(NAME , " React Native IDScanner starting" )
122122
123- if (apiKeys.isNull(KEY_MRZ_KEY ) || apiKeys.isNull(KEY_PDF_KEY ) || apiKeys.isNull(KEY_PARSER_KEY )) {
123+ val hasMRZKey = apiKeys.hasKey(KEY_MRZ_KEY ) && ! apiKeys.isNull(KEY_MRZ_KEY )
124+ val hasPDFKey = apiKeys.hasKey(KEY_PDF_KEY ) && ! apiKeys.isNull(KEY_PDF_KEY )
125+ val hasParserKey = apiKeys.hasKey(KEY_PARSER_KEY ) && ! apiKeys.isNull(KEY_PARSER_KEY )
126+
127+ if ((! hasMRZKey && ! hasPDFKey) || ! hasParserKey) {
124128 val scanResult = Arguments .createMap()
125129 scanResult.putString(" success" , " false" )
126130 callback.invoke(" Must provide activation keys for IDScan.net's Camera Scanner and ID Parser SDKs" )
127131 return
128132 }
129133
130134 scannerType = type
131- scannerMRZKey = apiKeys.getString(KEY_MRZ_KEY )
132- scannerPDFKey = apiKeys.getString(KEY_PDF_KEY )
135+ scannerMRZKey = if (hasMRZKey) apiKeys.getString(KEY_MRZ_KEY ) else " "
136+ scannerPDFKey = if (hasPDFKey) apiKeys.getString(KEY_PDF_KEY ) else " "
133137 parserKey = apiKeys.getString(KEY_PARSER_KEY )
134138
135139 this .callback = callback
@@ -151,18 +155,25 @@ class IdscanSdkModule(reactContext: ReactApplicationContext) :
151155
152156 private fun showDefaultScanView () {
153157 if (checkCameraPermissions()) {
154- MultiScanActivity .build(currentActivity!! )
155- .withComponent(
156- PDF417Component .build()
157- .withLicenseKey(scannerPDFKey!! )
158- .complete()
159- )
160- .withComponent(
158+ val multiScanActivity = MultiScanActivity .build(currentActivity!! )
159+
160+ if (! (scannerMRZKey!! ).isNullOrEmpty()){
161+ multiScanActivity.withComponent(
161162 MRZComponent .build()
162163 .withLicenseKey(scannerMRZKey!! )
163164 .complete()
164165 )
165- .start(SCAN_ACTIVITY_CODE )
166+ }
167+
168+ if (! (scannerPDFKey!! ).isNullOrEmpty()) {
169+ multiScanActivity.withComponent(
170+ PDF417Component .build()
171+ .withLicenseKey(scannerPDFKey!! )
172+ .complete()
173+ )
174+ }
175+
176+ multiScanActivity.start(SCAN_ACTIVITY_CODE )
166177 } else {
167178 requestCameraPermissions(REQUEST_CAMERA_PERMISSIONS_DEFAULT )
168179 }
0 commit comments