24
24
#import " MBOverlaySettingsSerializers.h"
25
25
#import " MBRecognizerWrapper.h"
26
26
#import " MBSerializationUtils.h"
27
+ #import " MBBlinkIDSerializationUtils.h"
27
28
28
29
#import < BlinkID/BlinkID.h>
29
-
30
- @interface CDVPlugin () <MBOverlayViewControllerDelegate, MBScanningRecognizerRunnerDelegate, MBFirstSideFinishedRecognizerRunnerDelegate>
30
+ @interface CDVPlugin () <MBOverlayViewControllerDelegate, MBScanningRecognizerRunnerDelegate, MBFirstSideFinishedRecognizerRunnerDelegate, MBBlinkIdMultiSideRecognizerDelegate, MBBlinkIdSingleSideRecognizerDelegate>
31
31
32
32
@property (nonatomic , retain ) CDVInvokedUrlCommand *lastCommand;
33
33
@@ -38,6 +38,8 @@ @interface CDVBlinkIDScanner ()
38
38
@property (nonatomic , strong ) MBRecognizerCollection *recognizerCollection;
39
39
@property (nonatomic ) id <MBRecognizerRunnerViewController> scanningViewController;
40
40
@property (nonatomic , strong ) MBRecognizerRunner *recognizerRunner;
41
+ @property (nonatomic , strong ) MBOverlayViewController *overlayVc;
42
+ @property (nonatomic , strong ) NSDictionary *jsonRecognizerCollection;
41
43
42
44
@property (class , nonatomic , readonly ) NSString *RESULT_LIST;
43
45
@property (class , nonatomic , readonly ) NSString *CANCELLED;
@@ -75,18 +77,27 @@ - (void)scanWithCamera:(CDVInvokedUrlCommand *)command {
75
77
[self setLastCommand: command];
76
78
77
79
NSDictionary *jsonOverlaySettings = [self sanitizeDictionary: [self .lastCommand argumentAtIndex: 0 ]];
78
- NSDictionary *jsonRecognizerCollection = [self sanitizeDictionary: [self .lastCommand argumentAtIndex: 1 ]];
80
+ _jsonRecognizerCollection = [self sanitizeDictionary: [self .lastCommand argumentAtIndex: 1 ]];
79
81
NSDictionary *jsonLicenses = [self sanitizeDictionary: [self .lastCommand argumentAtIndex: 2 ]];
80
82
81
83
if ([self setLicense: jsonLicenses]) {
82
84
[self setLanguage: (NSString *)jsonOverlaySettings[@" language" ] country: (NSString *)jsonOverlaySettings[@" country" ]];
83
85
84
- self.recognizerCollection = [[MBRecognizerSerializers sharedInstance ] deserializeRecognizerCollection: jsonRecognizerCollection ];
86
+ self.recognizerCollection = [[MBRecognizerSerializers sharedInstance ] deserializeRecognizerCollection: _jsonRecognizerCollection ];
85
87
86
88
// create overlay VC
87
- MBOverlayViewController *overlayVC = [[MBOverlaySettingsSerializers sharedInstance ] createOverlayViewController: jsonOverlaySettings recognizerCollection: self .recognizerCollection delegate: self ];
89
+ _overlayVc = [[MBOverlaySettingsSerializers sharedInstance ] createOverlayViewController: jsonOverlaySettings recognizerCollection: self .recognizerCollection delegate: self ];
90
+ for (MBRecognizer *recognizer in self.recognizerCollection .recognizerList ) {
91
+ if ([recognizer isKindOfClass: [MBBlinkIdMultiSideRecognizer class ]]) {
92
+ [(MBBlinkIdMultiSideRecognizer *)recognizer setDelegate: self ];
93
+ break ;
94
+ } else if ([recognizer isKindOfClass: [MBBlinkIdSingleSideRecognizer class ]]) {
95
+ [(MBBlinkIdSingleSideRecognizer *)recognizer setDelegate: self ];
96
+ break ;
97
+ }
98
+ }
88
99
89
- UIViewController<MBRecognizerRunnerViewController>* recognizerRunnerViewController = [MBViewControllerFactory recognizerRunnerViewControllerWithOverlayViewController: overlayVC ];
100
+ UIViewController<MBRecognizerRunnerViewController>* recognizerRunnerViewController = [MBViewControllerFactory recognizerRunnerViewControllerWithOverlayViewController: _overlayVc ];
90
101
[recognizerRunnerViewController setModalPresentationStyle: UIModalPresentationFullScreen];
91
102
92
103
self.scanningViewController = recognizerRunnerViewController;
@@ -245,6 +256,25 @@ - (void)overlayDidTapClose:(MBOverlayViewController *)overlayViewController {
245
256
CDVPluginResult *result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: resultDict];
246
257
[self .commandDelegate sendPluginResult: result callbackId: self .lastCommand.callbackId];
247
258
}
259
+ - (BOOL )multiSideClassInfoFilter : (nullable MBClassInfo *)classInfo {
260
+ return [MBBlinkIDSerializationUtils deserializeClassFilter: _jsonRecognizerCollection classInfo: classInfo];
261
+ }
262
+
263
+ - (void )onMultiSideDocumentSupportStatus : (BOOL )isDocumentSupported {
264
+ if ([_overlayVc isKindOfClass: [MBBlinkIdOverlayViewController class ]]) {
265
+ [(MBBlinkIdOverlayViewController *)_overlayVc onDocumentSupportStatus: isDocumentSupported];
266
+ }
267
+ }
268
+
269
+ - (BOOL )classInfoFilter : (MBClassInfo *)classInfo {
270
+ return [MBBlinkIDSerializationUtils deserializeClassFilter: _jsonRecognizerCollection classInfo: classInfo];
271
+ }
272
+
273
+ - (void )onDocumentSupportStatus : (BOOL )isDocumentSupported {
274
+ if ([_overlayVc isKindOfClass: [MBBlinkIdOverlayViewController class ]]) {
275
+ [(MBBlinkIdOverlayViewController *)_overlayVc onDocumentSupportStatus: isDocumentSupported];
276
+ }
277
+ } // TODO SSAD SERZITION UTILS
248
278
249
279
+ (NSString *)RESULT_LIST {
250
280
return @" resultList" ;
0 commit comments