@regulaforensics/cordova-plugin-document-reader-api 6.8.1 → 6.9.1

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.
@@ -1,31 +1,28 @@
1
1
  package cordova.plugin.documentreader;
2
2
 
3
- import org.json.JSONArray;
4
- import org.json.JSONObject;
5
- import org.json.JSONException;
6
-
7
- import com.regula.documentreader.api.DocumentReader;
8
- import com.regula.documentreader.api.params.ImageQA;
9
- import com.regula.documentreader.api.params.OnlineProcessingConfig;
10
- import com.regula.documentreader.api.params.ParamsCustomization;
11
- import com.regula.documentreader.api.params.Functionality;
12
- import com.regula.documentreader.api.params.ProcessParam;
13
- import com.regula.documentreader.api.params.rfid.RFIDParams;
14
- import com.regula.documentreader.api.params.rfid.ReprocParams;
15
- import com.regula.documentreader.api.params.rfid.dg.DataGroups;
3
+ import static cordova.plugin.documentreader.Helpers.*;
4
+ import static cordova.plugin.documentreader.JSONConstructor.*;
16
5
 
17
6
  import android.annotation.SuppressLint;
18
7
  import android.content.Context;
19
8
  import android.graphics.Paint;
9
+ import android.graphics.Typeface;
20
10
  import android.text.SpannableString;
21
11
  import android.widget.ImageView.ScaleType;
22
- import android.graphics.Typeface;
23
12
 
24
- import java.math.BigDecimal;
13
+ import com.regula.documentreader.api.DocumentReader;
14
+ import com.regula.documentreader.api.params.*;
15
+ import com.regula.documentreader.api.params.rfid.RFIDParams;
16
+ import com.regula.documentreader.api.params.rfid.ReprocParams;
17
+ import com.regula.documentreader.api.params.rfid.dg.DataGroups;
25
18
 
26
- import static cordova.plugin.documentreader.Helpers.*;
27
- import static cordova.plugin.documentreader.JSONConstructor.*;
19
+ import org.json.JSONArray;
20
+ import org.json.JSONException;
21
+ import org.json.JSONObject;
22
+
23
+ import java.math.BigDecimal;
28
24
 
25
+ @SuppressWarnings("deprecation")
29
26
  class RegulaConfig {
30
27
  static void setConfig(DocumentReader reader, JSONObject opts, Context context) throws JSONException {
31
28
  if (opts.has("customization"))
@@ -191,11 +188,8 @@ class RegulaConfig {
191
188
  processParams.fastDocDetect = opts.getBoolean("fastDocDetect");
192
189
  if (opts.has("updateOCRValidityByGlare"))
193
190
  processParams.updateOCRValidityByGlare = opts.getBoolean("updateOCRValidityByGlare");
194
- if (opts.has("imageQA")) {
195
- ImageQA img = new ImageQA();
196
- img.fromJson(opts.getJSONObject("imageQA"));
197
- processParams.imageQA = img;
198
- }
191
+ if (opts.has("imageQA"))
192
+ processParams.imageQA = ImageQAFromJSON(opts.getJSONObject("imageQA"));
199
193
  if (opts.has("forceDocFormat"))
200
194
  processParams.forceDocFormat = opts.getInt("forceDocFormat");
201
195
  if (opts.has("noGraphics"))
@@ -234,6 +228,12 @@ class RegulaConfig {
234
228
  processParams.doFlipYAxis = opts.getBoolean("doFlipYAxis");
235
229
  if (opts.has("rfidParams"))
236
230
  processParams.rfidParams = RFIDParamsFromJSON(opts.getJSONObject("rfidParams"));
231
+ if (opts.has("doDetectCan"))
232
+ processParams.doDetectCan = opts.getBoolean("doDetectCan");
233
+ if (opts.has("faceApiParams"))
234
+ processParams.faceApiParams = FaceApiParamsFromJSON(opts.getJSONObject("faceApiParams"));
235
+ if (opts.has("useFaceApi"))
236
+ processParams.useFaceApi = opts.getBoolean("useFaceApi");
237
237
  }
238
238
 
239
239
  private static void setCustomization(ParamsCustomization customization, JSONObject opts, Context context) throws JSONException {
@@ -308,12 +308,16 @@ class RegulaConfig {
308
308
  editor.setMultipageAnimationFrontImageScaleType(ScaleType.valueOf(opts.getString("multipageAnimationFrontImageScaleType")));
309
309
  if (opts.has("multipageAnimationBackImageScaleType"))
310
310
  editor.setMultipageAnimationBackImageScaleType(ScaleType.valueOf(opts.getString("multipageAnimationBackImageScaleType")));
311
+ if (opts.has("borderBackgroundImageScaleType"))
312
+ editor.setBorderBackgroundImageScaleType(ScaleType.valueOf(opts.getString("borderBackgroundImageScaleType")));
311
313
  if (opts.has("helpAnimationImageMatrix"))
312
314
  editor.setHelpAnimationImageMatrix(matrixFromFloatArray(floatArrayFromJson(opts.getJSONArray("helpAnimationImageMatrix"))));
313
315
  if (opts.has("multipageAnimationFrontImageMatrix"))
314
316
  editor.setMultipageAnimationFrontImageMatrix(matrixFromFloatArray(floatArrayFromJson(opts.getJSONArray("multipageAnimationFrontImageMatrix"))));
315
317
  if (opts.has("multipageAnimationBackImageMatrix"))
316
318
  editor.setMultipageAnimationBackImageMatrix(matrixFromFloatArray(floatArrayFromJson(opts.getJSONArray("multipageAnimationBackImageMatrix"))));
319
+ if (opts.has("borderBackgroundImageMatrix"))
320
+ editor.setBorderBackgroundImageMatrix(matrixFromFloatArray(floatArrayFromJson(opts.getJSONArray("borderBackgroundImageMatrix"))));
317
321
  if (opts.has("customStatusPositionMultiplier"))
318
322
  editor.setCustomStatusPositionMultiplier((float) opts.getDouble("customStatusPositionMultiplier"));
319
323
  if (opts.has("cameraFrameVerticalPositionMultiplier"))
@@ -432,9 +436,11 @@ class RegulaConfig {
432
436
  object.put("helpAnimationImageScaleType", customization.getHelpAnimationImageScaleType());
433
437
  object.put("multipageAnimationFrontImageScaleType", customization.getMultipageAnimationFrontImageScaleType());
434
438
  object.put("multipageAnimationBackImageScaleType", customization.getMultipageAnimationBackImageScaleType());
439
+ object.put("borderBackgroundImageScaleType", customization.getBorderBackgroundImageScaleType());
435
440
  object.put("helpAnimationImageMatrix", customization.getHelpAnimationImageMatrix());
436
441
  object.put("multipageAnimationFrontImageMatrix", customization.getMultipageAnimationFrontImageMatrix());
437
442
  object.put("multipageAnimationBackImageMatrix", customization.getMultipageAnimationBackImageMatrix());
443
+ object.put("borderBackgroundImageMatrix", customization.getBorderBackgroundImageMatrix());
438
444
  object.put("statusTextFont", customization.getStatusTextFont());
439
445
  object.put("resultStatusTextFont", customization.getResultStatusTextFont());
440
446
  object.put("statusPositionMultiplier", customization.getStatusPositionMultiplier());
@@ -475,7 +481,6 @@ class RegulaConfig {
475
481
  object.put("documentIDList", processParams.documentIDList != null ? generateIntArray(processParams.documentIDList) : null);
476
482
  object.put("barcodeTypes", processParams.doBarcodes != null ? generateArray(processParams.doBarcodes) : null);
477
483
  object.put("fieldTypesFilter", processParams.fieldTypesFilter != null ? generateIntArray(processParams.fieldTypesFilter) : null);
478
- object.put("faceMetaData", processParams.faceMetaData != null ? generateArray(processParams.faceMetaData, JSONConstructor::generateFaceMetaData) : null);
479
484
  object.put("scenario", processParams.scenario);
480
485
  object.put("measureSystem", processParams.measureSystem);
481
486
  object.put("uvTorchEnabled", processParams.uvTorchEnabled);
@@ -512,7 +517,7 @@ class RegulaConfig {
512
517
  object.put("matchTextFieldMask", processParams.matchTextFieldMask);
513
518
  object.put("fastDocDetect", processParams.fastDocDetect);
514
519
  object.put("updateOCRValidityByGlare", processParams.updateOCRValidityByGlare);
515
- object.put("imageQA", processParams.imageQA.toJsonObject());
520
+ object.put("imageQA", generateImageQA(processParams.imageQA));
516
521
  object.put("forceDocFormat", processParams.forceDocFormat);
517
522
  object.put("noGraphics", processParams.noGraphics);
518
523
  object.put("documentAreaMin", processParams.documentAreaMin);
@@ -531,6 +536,8 @@ class RegulaConfig {
531
536
  object.put("splitNames", processParams.splitNames);
532
537
  object.put("convertCase", processParams.convertCase);
533
538
  object.put("doFlipYAxis", processParams.doFlipYAxis);
539
+ object.put("doDetectCan", processParams.doDetectCan);
540
+ object.put("useFaceApi", processParams.useFaceApi);
534
541
 
535
542
  return object;
536
543
  }
@@ -695,6 +702,8 @@ class RegulaConfig {
695
702
  else return null;
696
703
  if (input.has("failIfNoService"))
697
704
  result.setFailIfNoService(input.getBoolean("failIfNoService"));
705
+ if (input.has("httpHeaders"))
706
+ result.setHttpHeaders(stringMapFromJson(input.getJSONObject("httpHeaders")));
698
707
  return result;
699
708
  } catch (JSONException e) {
700
709
  e.printStackTrace();
@@ -702,7 +711,8 @@ class RegulaConfig {
702
711
  return null;
703
712
  }
704
713
 
705
- private static OnlineProcessingConfig OnlineProcessingConfigFromJSON(JSONObject input) {
714
+ static OnlineProcessingConfig OnlineProcessingConfigFromJSON(JSONObject input) {
715
+ if(input == null) return null;
706
716
  try {
707
717
  OnlineProcessingConfig.Builder builder;
708
718
  if (input.has("mode"))
@@ -731,8 +741,86 @@ class RegulaConfig {
731
741
  RFIDParams result = new RFIDParams();
732
742
 
733
743
  if (input.has("paIgnoreNotificationCodes"))
734
- result.setPaIgnoreNotificationCodes(JSONConstructor.intArrayFromJSON(input.getJSONArray("paIgnoreNotificationCodes")));
744
+ result.setPaIgnoreNotificationCodes(intArrayFromJSON(input.getJSONArray("paIgnoreNotificationCodes")));
745
+
746
+ return result;
747
+ } catch (JSONException e) {
748
+ e.printStackTrace();
749
+ }
750
+ return null;
751
+ }
752
+
753
+ static FaceApiParams FaceApiParamsFromJSON(JSONObject input) {
754
+ try {
755
+ FaceApiParams result = new FaceApiParams();
756
+ String url;
757
+ if (input.has("url") && !input.isNull("url")) {
758
+ url = input.getString("url");
759
+ result.setUrl(url);
760
+ }
761
+ String mode;
762
+ if (input.has("mode") && !input.isNull("mode")) {
763
+ mode = input.getString("mode");
764
+ result.setMode(mode);
765
+ }
766
+ FaceApiParams.Search search;
767
+ if (input.has("searchParams") && !input.isNull("searchParams")) {
768
+ search = SearchFromJSON(input.getJSONObject("searchParams"));
769
+ result.setSearch(search);
770
+ }
771
+ int threshold;
772
+ if (input.has("threshold") && !input.isNull("threshold")) {
773
+ threshold = input.getInt("threshold");
774
+ result.setThreshold(threshold);
775
+ }
776
+ int serviceTimeout;
777
+ if (input.has("serviceTimeout") && !input.isNull("serviceTimeout")) {
778
+ serviceTimeout = input.getInt("serviceTimeout");
779
+ result.setServiceTimeout(serviceTimeout);
780
+ }
781
+ String proxy;
782
+ if (input.has("proxy") && !input.isNull("proxy")) {
783
+ proxy = input.getString("proxy");
784
+ result.setProxy(proxy);
785
+ }
786
+ String proxyUserPwd;
787
+ if (input.has("proxyPassword") && !input.isNull("proxyPassword")) {
788
+ proxyUserPwd = input.getString("proxyPassword");
789
+ result.setProxyUserPwd(proxyUserPwd);
790
+ }
791
+ int proxyType;
792
+ if (input.has("proxyType") && !input.isNull("proxyType")) {
793
+ proxyType = input.getInt("proxyType");
794
+ result.setProxyType(proxyType);
795
+ }
796
+ return result;
797
+ } catch (JSONException e) {
798
+ e.printStackTrace();
799
+ }
800
+ return null;
801
+ }
735
802
 
803
+ static FaceApiParams.Search SearchFromJSON(JSONObject input) {
804
+ try {
805
+ FaceApiParams.Search result = new FaceApiParams.Search();
806
+ int limit;
807
+ if (input.has("limit") && !input.isNull("limit")) {
808
+ limit = input.getInt("limit");
809
+ result.setLimit(limit);
810
+ }
811
+ double threshold;
812
+ if (input.has("threshold") && !input.isNull("threshold")) {
813
+ threshold = input.getDouble("threshold");
814
+ result.setThreshold((float) threshold);
815
+ }
816
+ int[] groupIds;
817
+ if (input.has("groupIds") && !input.isNull("groupIds")) {
818
+ JSONArray jsonArray_groupIds = input.getJSONArray("groupIds");
819
+ groupIds = new int[jsonArray_groupIds.length()];
820
+ for (int i = 0; i < jsonArray_groupIds.length(); i++)
821
+ groupIds[i] = jsonArray_groupIds.getInt(i);
822
+ result.setGroupIds(groupIds);
823
+ }
736
824
  return result;
737
825
  } catch (JSONException e) {
738
826
  e.printStackTrace();
@@ -1,5 +1,13 @@
1
1
  apply plugin: 'kotlin-android'
2
2
 
3
+ android {
4
+ compileSdkVersion 33
5
+
6
+ defaultConfig {
7
+ targetSdkVersion 33
8
+ }
9
+ }
10
+
3
11
  repositories {
4
12
  maven {
5
13
  url "https://maven.regulaforensics.com/RegulaDocumentReader"
@@ -8,7 +16,7 @@ repositories {
8
16
 
9
17
  dependencies {
10
18
  //noinspection GradleDependency
11
- implementation ('com.regula.documentreader:api:6.8.8742'){
19
+ implementation ('com.regula.documentreader:api:6.9.9406'){
12
20
  transitive = true
13
21
  }
14
22
  }
@@ -6,7 +6,10 @@ RGLRFIDCertificatesCallback RGLWPaCertificateCompletion;
6
6
  RGLRFIDCertificatesCallback RGLWTaCertificateCompletion;
7
7
  RGLWRFIDSignatureCallback RGLWTaSignatureCompletion;
8
8
 
9
- NSString* RGLWRfidNotificationCompletionEvent = @"rfidNotificationCompletionEvent";
9
+ NSString* RGLWRfidOnProgressEvent = @"rfidNotificationCompletionEvent";
10
+ NSString* RGLWRfidOnChipDetectedEvent = @"rfidOnChipDetectedEvent";
11
+ NSString* RGLWRfidOnRetryReadChipEvent = @"rfidOnRetryReadChipEvent";
12
+
10
13
  NSString* RGLWPaCertificateCompletionEvent = @"paCertificateCompletionEvent";
11
14
  NSString* RGLWTaCertificateCompletionEvent = @"taCertificateCompletionEvent";
12
15
  NSString* RGLWTaSignatureCompletionEvent = @"taSignatureCompletionEvent";
@@ -28,11 +31,13 @@ RGLWDocumentReader* RGLWPlugin;
28
31
  }
29
32
 
30
33
  - (void)didChipConnected {
31
- [RGLWPlugin sendEvent:[NSString stringWithFormat:@"%@%@", RGLWRfidNotificationCompletionEvent, [RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateRfidNotificationCompletion:1]]] :RGLWDocumentReader.command.callbackId]; // int RFID_EVENT_CHIP_DETECTED = 1;
34
+ [RGLWPlugin sendEvent:[NSString stringWithFormat:@"%@%@", RGLWRfidOnChipDetectedEvent, @""] :RGLWDocumentReader.command.callbackId];
32
35
  }
33
36
 
34
37
  - (void)didReceivedError:(RGLRFIDErrorCodes)errorCode {
35
- [RGLWPlugin sendEvent:[NSString stringWithFormat:@"%@%@", RGLWRfidNotificationCompletionEvent, [RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateRfidNotificationCompletionWithError:2:errorCode]]] :RGLWDocumentReader.command.callbackId]; // int RFID_EVENT_READING_ERROR = 2;
38
+ NSMutableDictionary *result = [NSMutableDictionary new];
39
+ result[@"errorCode"] = [NSNumber numberWithInteger:errorCode];
40
+ [RGLWPlugin sendEvent:[NSString stringWithFormat:@"%@%@", RGLWRfidOnRetryReadChipEvent, [RGLWJSONConstructor dictToString:result]] :RGLWDocumentReader.command.callbackId];
36
41
  }
37
42
 
38
43
  @end
@@ -71,21 +76,21 @@ static CDVInvokedUrlCommand* _command;
71
76
  -(RGLDocumentReaderCompletion _Nonnull)getCompletion {
72
77
  NSString* callbackId = RGLWDocumentReader.command.callbackId;
73
78
  return ^(RGLDocReaderAction action, RGLDocumentReaderResults * _Nullable results, NSError * _Nullable error) {
74
- [self sendEvent:[RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateCompletion:[RGLWJSONConstructor generateDocReaderAction: action] :results :error :nil]] :callbackId];
79
+ [self sendEvent:[RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateCompletion:[RGLWJSONConstructor generateDocReaderAction: action] :results :error]] :callbackId];
75
80
  };
76
81
  }
77
82
 
78
83
  -(RGLRFIDProcessCompletion _Nonnull)getRFIDCompletion {
79
84
  NSString* callbackId = RGLWDocumentReader.command.callbackId;
80
85
  return ^(RGLRFIDCompleteAction action, RGLDocumentReaderResults * _Nullable results, NSError * _Nullable error, RGLRFIDErrorCodes errorCode) {
81
- [self sendEvent:[RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateCompletion:[RGLWJSONConstructor generateRFIDCompleteAction: action] :results :error :nil]] :callbackId];
86
+ [self sendEvent:[RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateCompletion:[RGLWJSONConstructor generateRFIDCompleteAction: action] :results :error]] :callbackId];
82
87
  };
83
88
  }
84
89
 
85
90
  -(RGLRFIDNotificationCallback _Nonnull)getRFIDNotificationCallback {
86
91
  NSString* callbackId = RGLWDocumentReader.command.callbackId;
87
- return ^(RGLRFIDNotificationAction notificationAction, RGLRFIDNotify* _Nullable notify) {
88
- [self sendEvent:[RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateCompletion:[RGLWJSONConstructor generateRFIDNotificationAction:notificationAction] :nil :nil :notify]] :callbackId];
92
+ return ^(RGLRFIDNotificationAction action, RGLRFIDNotify* _Nullable notification) {
93
+ [self sendEvent:[RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateDocumentReaderNotification:notification]] :callbackId];
89
94
  };
90
95
  }
91
96
 
@@ -115,11 +120,13 @@ static CDVInvokedUrlCommand* _command;
115
120
  }
116
121
 
117
122
  - (void)didChipConnected {
118
- [RGLWPlugin sendEvent:[NSString stringWithFormat:@"%@%@", RGLWRfidNotificationCompletionEvent, [RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateRfidNotificationCompletion:1]]] :RGLWDocumentReader.command.callbackId]; // int RFID_EVENT_CHIP_DETECTED = 1;
123
+ [RGLWPlugin sendEvent:[NSString stringWithFormat:@"%@%@", RGLWRfidOnChipDetectedEvent, @""] :RGLWDocumentReader.command.callbackId];
119
124
  }
120
125
 
121
126
  - (void)didReceivedError:(RGLRFIDErrorCodes)errorCode {
122
- [RGLWPlugin sendEvent:[NSString stringWithFormat:@"%@%@", RGLWRfidNotificationCompletionEvent, [RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateRfidNotificationCompletionWithError:2:errorCode]]] :RGLWDocumentReader.command.callbackId]; // int RFID_EVENT_READING_ERROR = 2;
127
+ NSMutableDictionary *result = [NSMutableDictionary new];
128
+ result[@"errorCode"] = [NSNumber numberWithInteger:errorCode];
129
+ [RGLWPlugin sendEvent:[NSString stringWithFormat:@"%@%@", RGLWRfidOnRetryReadChipEvent, [RGLWJSONConstructor dictToString:result]] :RGLWDocumentReader.command.callbackId];
123
130
  }
124
131
 
125
132
  - (void)onCustomButtonTappedWithTag:(NSInteger)tag {
@@ -234,8 +241,10 @@ static CDVInvokedUrlCommand* _command;
234
241
  [self setTag :[args objectAtIndex:0] :successCallback :errorCallback];
235
242
  else if([action isEqualToString:@"checkDatabaseUpdate"])
236
243
  [self checkDatabaseUpdate :[args objectAtIndex:0] :successCallback :errorCallback];
237
- else if([action isEqualToString:@"getScenario"])
238
- [self getScenario :[args objectAtIndex:0] :successCallback :errorCallback];
244
+ else if([action isEqualToString:@"scan"])
245
+ [self scan :[args objectAtIndex:0] :successCallback :errorCallback];
246
+ else if([action isEqualToString:@"recognize"])
247
+ [self recognize :[args objectAtIndex:0] :successCallback :errorCallback];
239
248
  else if([action isEqualToString:@"recognizeImages"])
240
249
  [self recognizeImages :[args objectAtIndex:0] :successCallback :errorCallback];
241
250
  else if([action isEqualToString:@"showScannerWithCameraID"])
@@ -276,8 +285,6 @@ static CDVInvokedUrlCommand* _command;
276
285
  [self recognizeImageWithCameraMode :[args objectAtIndex:0] :[args objectAtIndex:1] :successCallback :errorCallback];
277
286
  else if([action isEqualToString:@"recognizeImagesWithImageInputs"])
278
287
  [self recognizeImagesWithImageInputs :[args objectAtIndex:0] :successCallback :errorCallback];
279
- else if([action isEqualToString:@"setOnCustomButtonTappedListener"])
280
- [self setOnCustomButtonTappedListener :successCallback :errorCallback];
281
288
  else if([action isEqualToString:@"setLanguage"])
282
289
  [self setLanguage :[args objectAtIndex:0] :successCallback :errorCallback];
283
290
  else if([action isEqualToString:@"textFieldValueByType"])
@@ -373,11 +380,6 @@ static CDVInvokedUrlCommand* _command;
373
380
  [self result:@"getLicenseMessage() is an android-only method" :successCallback];
374
381
  }
375
382
 
376
- - (void) setOnCustomButtonTappedListener:(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
377
- RGLDocReader.shared.customization.actionDelegate = self;
378
- [self result:@"" :successCallback];
379
- }
380
-
381
383
  - (void) setLanguage:(NSString*)language :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
382
384
  RGLDocReader.shared.localizationHandler = ^NSString * _Nullable(NSString * _Nonnull localizationKey) {
383
385
  NSString *result = NSLocalizedStringFromTable(localizationKey, language, @"");
@@ -445,7 +447,7 @@ static CDVInvokedUrlCommand* _command;
445
447
  - (void) recognizeImages:(NSArray*)input :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
446
448
  NSMutableArray<UIImage*>* images = [[NSMutableArray alloc] init];
447
449
  for(__strong NSMutableString* base64 in input)
448
- [images addObject:[UIImage imageWithData:[[NSData alloc]initWithBase64EncodedString:base64 options:NSDataBase64DecodingIgnoreUnknownCharacters]]];
450
+ [images addObject:[RGLWJSONConstructor imageWithBase64:base64]];
449
451
  dispatch_async(dispatch_get_main_queue(), ^{
450
452
  [RGLDocReader.shared recognizeImages:images completion:[self getCompletion]];
451
453
  });
@@ -467,7 +469,7 @@ static CDVInvokedUrlCommand* _command;
467
469
 
468
470
  - (void) recognizeImageWith:(NSMutableString*)base64 :(BOOL)cameraMode :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
469
471
  dispatch_async(dispatch_get_main_queue(), ^{
470
- [RGLDocReader.shared recognizeImage:[UIImage imageWithData:[[NSData alloc]initWithBase64EncodedString:base64 options:NSDataBase64DecodingIgnoreUnknownCharacters]] cameraMode:cameraMode completion:[self getCompletion]];
472
+ [RGLDocReader.shared recognizeImage:[RGLWJSONConstructor imageWithBase64:base64] cameraMode:cameraMode completion:[self getCompletion]];
471
473
  });
472
474
  }
473
475
 
@@ -550,6 +552,21 @@ static CDVInvokedUrlCommand* _command;
550
552
  [self result:@"" :successCallback];
551
553
  }
552
554
 
555
+ - (void) scan:(NSDictionary*)config :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
556
+ dispatch_async(dispatch_get_main_queue(), ^{
557
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
558
+ [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
559
+ #pragma clang diagnostic pop
560
+ UIViewController *currentViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];
561
+ [RGLDocReader.shared showScannerFromPresenter:currentViewController config:[RGLWJSONConstructor RGLScannerConfigFromJson:config] completion:[self getCompletion]];
562
+ });
563
+ }
564
+
565
+ - (void) recognize:(NSDictionary*)config :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
566
+ UIViewController *currentViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];
567
+ [RGLDocReader.shared recognizeImageFromPresenter:currentViewController config:[RGLWJSONConstructor RGLRecognizeConfigFromJson:config] completion:[self getCompletion]];
568
+ }
569
+
553
570
  - (void) getDocumentReaderIsReady:(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
554
571
  [self result:[RGLDocReader.shared isDocumentReaderIsReady] ? @YES : @NO :successCallback];
555
572
  }
@@ -651,18 +668,6 @@ static CDVInvokedUrlCommand* _command;
651
668
  [self result:RGLDocReader.shared.processParams.sessionLogFolder :successCallback];
652
669
  }
653
670
 
654
- - (void) getScenario:(NSString*)scenarioID :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
655
- BOOL success = false;
656
- for(RGLScenario *scenario in RGLDocReader.shared.availableScenarios)
657
- if([scenario.identifier isEqualToString:scenarioID]){
658
- [self result:[RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateRGLScenario:scenario]] :successCallback];
659
- success = true;
660
- break;
661
- }
662
- if(!success)
663
- [self result:@"Scenario unavailable" :errorCallback];
664
- }
665
-
666
671
  - (void) providePACertificates:(NSArray*)input :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
667
672
  if(RGLWPaCertificateCompletion == nil){
668
673
  [self result:@"paCertificateCompletion is nil" :errorCallback];
@@ -796,22 +801,22 @@ static CDVInvokedUrlCommand* _command;
796
801
 
797
802
  - (void) graphicFieldImageByType:(NSString*)rawResult :(NSNumber*)fieldType :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
798
803
  RGLDocumentReaderResults* results = [RGLDocumentReaderResults initWithRawString:rawResult];
799
- [self result:[UIImageJPEGRepresentation([results getGraphicFieldImageByType:[fieldType integerValue]], 1.0) base64EncodedStringWithOptions:0] :successCallback];
804
+ [self result:[RGLWJSONConstructor base64WithImage:[results getGraphicFieldImageByType:[fieldType integerValue]]] :successCallback];
800
805
  }
801
806
 
802
807
  - (void) graphicFieldImageByTypeSource:(NSString*)rawResult :(NSNumber*)fieldType :(NSNumber*)source :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
803
808
  RGLDocumentReaderResults* results = [RGLDocumentReaderResults initWithRawString:rawResult];
804
- [self result:[UIImageJPEGRepresentation([results getGraphicFieldImageByType:[fieldType integerValue] source:[source integerValue]], 1.0) base64EncodedStringWithOptions:0] :successCallback];
809
+ [self result:[RGLWJSONConstructor base64WithImage:[results getGraphicFieldImageByType:[fieldType integerValue] source:[source integerValue]]] :successCallback];
805
810
  }
806
811
 
807
812
  - (void) graphicFieldImageByTypeSourcePageIndex:(NSString*)rawResult :(NSNumber*)fieldType :(NSNumber*)source :(NSNumber*)pageIndex :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
808
813
  RGLDocumentReaderResults* results = [RGLDocumentReaderResults initWithRawString:rawResult];
809
- [self result:[UIImageJPEGRepresentation([results getGraphicFieldImageByType:[fieldType integerValue] source:[source integerValue] pageIndex:[pageIndex integerValue]], 1.0) base64EncodedStringWithOptions:0] :successCallback];
814
+ [self result:[RGLWJSONConstructor base64WithImage:[results getGraphicFieldImageByType:[fieldType integerValue] source:[source integerValue] pageIndex:[pageIndex integerValue]]] :successCallback];
810
815
  }
811
816
 
812
817
  - (void) graphicFieldImageByTypeSourcePageIndexLight:(NSString*)rawResult :(NSNumber*)fieldType :(NSNumber*)source :(NSNumber*)pageIndex :(NSNumber*)light :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
813
818
  RGLDocumentReaderResults* results = [RGLDocumentReaderResults initWithRawString:rawResult];
814
- [self result:[UIImageJPEGRepresentation([results getGraphicFieldImageByType:[fieldType integerValue] source:[source integerValue] pageIndex:[pageIndex integerValue] light:[light integerValue]], 1.0) base64EncodedStringWithOptions:0] :successCallback];
819
+ [self result:[RGLWJSONConstructor base64WithImage:[results getGraphicFieldImageByType:[fieldType integerValue] source:[source integerValue] pageIndex:[pageIndex integerValue] light:[light integerValue]]] :successCallback];
815
820
  }
816
821
 
817
822
  - (void) containers:(NSString*)rawResult :(NSArray<NSNumber*>*)resultType :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
@@ -828,6 +833,7 @@ static CDVInvokedUrlCommand* _command;
828
833
  return ^(BOOL successful, NSError * _Nullable error ) {
829
834
  if (successful){
830
835
  [RGLDocReader shared].functionality.recordScanningProcessDelegate = self;
836
+ RGLDocReader.shared.customization.actionDelegate = self;
831
837
  [self result:@"init complete" :successCallback];
832
838
  }else
833
839
  [self result:[NSString stringWithFormat:@"%@/%@", @"init failed: ", error.description] :errorCallback];
@@ -2,27 +2,29 @@
2
2
  #define RGLWJSONConstructor_h
3
3
 
4
4
  #import <DocumentReader/DocumentReader.h>
5
+ #import "RGLWRegulaConfig.h"
5
6
  @import CoreGraphics;
6
7
  @import UIKit;
7
8
 
8
9
  @interface RGLWJSONConstructor : NSObject
9
10
  +(NSString* _Nonnull)dictToString:(NSMutableDictionary* _Nonnull)input;
10
11
  +(NSString* _Nonnull)arrayToString:(NSMutableArray* _Nonnull)input;
11
- +(NSMutableDictionary* _Nonnull)generateRfidNotificationCompletion:(NSInteger)notification;
12
- +(NSMutableDictionary* _Nonnull)generateRfidNotificationCompletionWithError:(NSInteger)notification : (NSInteger)value;
13
12
  +(NSMutableDictionary* _Nonnull)generateNSDictionary:(NSDictionary<NSNumber*, NSNumber*>* _Nullable)input;
13
+ +(UIImage* _Nullable)imageWithBase64:(NSString* _Nullable)input;
14
+ +(NSString* _Nullable)base64WithImage:(UIImage* _Nullable)input;
14
15
  +(RGLPKDCertificate* _Nullable)RGLPKDCertificateFromJson:(NSDictionary* _Nullable) dict;
15
16
  +(RGLTCCParams* _Nonnull)RGLTCCParamsFromJson:(NSDictionary* _Nonnull)input;
16
17
  +(RGLConfig* _Nullable)RGLConfigFromJson:(NSDictionary* _Nonnull)input;
18
+ +(RGLScannerConfig* _Nullable)RGLScannerConfigFromJson:(NSDictionary* _Nonnull)input;
19
+ +(RGLRecognizeConfig* _Nullable)RGLRecognizeConfigFromJson:(NSDictionary* _Nonnull)input;
17
20
  +(RGLImageInput* _Nonnull)RGLImageInputFromJson:(NSDictionary* _Nonnull)input;
18
21
  +(NSInteger)generateDocReaderAction:(RGLDocReaderAction)action;
19
22
  +(NSInteger)generateRFIDCompleteAction:(RGLRFIDCompleteAction)action;
20
- +(NSInteger)generateRFIDNotificationAction:(RGLRFIDNotificationAction)action;
21
- +(NSMutableDictionary* _Nullable)generateCompletion:(NSInteger)action :(RGLDocumentReaderResults*_Nullable)results :(NSError*_Nullable)error :(RGLRFIDNotify*_Nullable)notify;
23
+ +(NSMutableDictionary* _Nullable)generateCompletion:(NSInteger)action :(RGLDocumentReaderResults*_Nullable)results :(NSError*_Nullable)error;
22
24
  +(NSMutableDictionary* _Nonnull)generateVideoEncoderCompletion:(NSURL* _Nullable)input :(NSError* _Nullable)error;
23
25
  +(NSString*_Nonnull)generateNSData:(NSData *_Nullable)input;
24
26
  +(NSMutableDictionary* _Nonnull)generatePACertificateCompletion:(NSData *_Nullable)serialNumber :(RGLPAResourcesIssuer *_Nullable)issuer;
25
- +(NSMutableDictionary* _Nonnull)generateRGLRFIDNotify:(RGLRFIDNotify* _Nullable)input;
27
+ +(NSMutableDictionary* _Nonnull)generateDocumentReaderNotification:(RGLRFIDNotify* _Nullable)input;
26
28
  +(NSMutableDictionary* _Nonnull)generateRGLDocumentReaderResults:(RGLDocumentReaderResults* _Nullable)input;
27
29
  +(NSMutableDictionary* _Nonnull)generateRGLPosition:(RGLPosition* _Nullable)input;
28
30
  +(NSMutableDictionary* _Nonnull)generateRGLDocumentReaderBarcodeResult:(RGLDocumentReaderBarcodeResult* _Nullable)input;
@@ -41,6 +43,7 @@
41
43
  +(NSMutableDictionary* _Nonnull)generateRGLDocumentReaderDocumentType:(RGLDocumentReaderDocumentType* _Nullable)input;
42
44
  +(NSMutableDictionary* _Nonnull)generateRGLScenario:(RGLScenario* _Nullable)input;
43
45
  +(NSMutableDictionary* _Nonnull)generateRGLRFIDSessionData:(RGLRFIDSessionData* _Nullable)input;
46
+ +(NSMutableDictionary* _Nonnull)generateRGLDataField:(RGLDataField* _Nullable)input;
44
47
  +(NSMutableDictionary* _Nonnull)generateRGLCardProperties:(RGLCardProperties* _Nullable)input;
45
48
  +(NSMutableDictionary* _Nonnull)generateRGLRFIDSessionDataStatus:(RGLRFIDSessionDataStatus* _Nullable)input;
46
49
  +(NSMutableDictionary* _Nonnull)generateRGLAccessControlProcedureType:(RGLAccessControlProcedureType* _Nullable)input;
@@ -57,7 +60,6 @@
57
60
  +(NSMutableDictionary* _Nonnull)generateRGLExtension:(RGLExtension* _Nullable)input;
58
61
  +(NSMutableDictionary* _Nonnull)generateRGLCertificateChain:(RGLCertificateChain* _Nullable)input;
59
62
  +(NSMutableDictionary* _Nonnull)generateRGLValidity:(RGLValidity* _Nullable)input;
60
- +(NSMutableDictionary* _Nonnull)generateNSError:(NSError* _Nullable)input;
61
63
  +(NSMutableDictionary* _Nonnull)generateRGLPAResourcesIssuer:(RGLPAResourcesIssuer* _Nullable)input;
62
64
  +(NSMutableDictionary* _Nonnull)generateRGLPAAttribute:(RGLPAAttribute* _Nullable)input;
63
65
  +(NSMutableDictionary* _Nonnull)generateRGLTAChallenge:(RGLTAChallenge* _Nullable)input;