anyline-ocr-react-native-module 53.3.0 → 54.0.0

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 (32) hide show
  1. package/android/.gradle/7.6/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.6/checksums/md5-checksums.bin +0 -0
  3. package/android/.gradle/7.6/checksums/sha1-checksums.bin +0 -0
  4. package/android/.gradle/7.6/dependencies-accessors/dependencies-accessors.lock +0 -0
  5. package/android/.gradle/7.6/dependencies-accessors/gc.properties +0 -0
  6. package/android/.gradle/7.6/executionHistory/executionHistory.lock +0 -0
  7. package/android/.gradle/7.6/fileChanges/last-build.bin +0 -0
  8. package/android/.gradle/7.6/fileHashes/fileHashes.bin +0 -0
  9. package/android/.gradle/7.6/fileHashes/fileHashes.lock +0 -0
  10. package/android/.gradle/7.6/gc.properties +0 -0
  11. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  12. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  13. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  14. package/android/.gradle/config.properties +2 -0
  15. package/android/.gradle/vcs-1/gc.properties +0 -0
  16. package/android/.idea/compiler.xml +6 -0
  17. package/android/.idea/gradle.xml +17 -0
  18. package/android/.idea/migrations.xml +10 -0
  19. package/android/.idea/misc.xml +10 -0
  20. package/android/.idea/other.xml +296 -0
  21. package/android/.idea/vcs.xml +6 -0
  22. package/android/build.gradle +1 -1
  23. package/android/local.properties +8 -0
  24. package/android/src/main/java/com/anyline/reactnative/ScanActivity.java +1 -1
  25. package/ios/ALJsonUIConfiguration.m +3 -0
  26. package/ios/ALPluginHelper.h +0 -2
  27. package/ios/ALPluginHelper.m +26 -60
  28. package/ios/AnylineReact.podspec +2 -2
  29. package/ios/AnylineSDKPlugin.m +12 -39
  30. package/package.json +8 -8
  31. package/ios/ALNFCScanViewController.h +0 -15
  32. package/ios/ALNFCScanViewController.m +0 -462
File without changes
@@ -0,0 +1,2 @@
1
+ #Mon Aug 26 14:07:33 IST 2024
2
+ gradle.version=7.6
@@ -0,0 +1,2 @@
1
+ #Mon Aug 26 14:06:49 IST 2024
2
+ java.home=/Applications/Android Studio.app/Contents/jbr/Contents/Home
File without changes
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="CompilerConfiguration">
4
+ <bytecodeTargetLevel target="17" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="GradleSettings">
4
+ <option name="linkedExternalProjectsSettings">
5
+ <GradleProjectSettings>
6
+ <option name="externalProjectPath" value="$PROJECT_DIR$" />
7
+ <option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
8
+ <option name="modules">
9
+ <set>
10
+ <option value="$PROJECT_DIR$" />
11
+ </set>
12
+ </option>
13
+ <option name="resolveExternalAnnotations" value="false" />
14
+ </GradleProjectSettings>
15
+ </option>
16
+ </component>
17
+ </project>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectMigrations">
4
+ <option name="MigrateToGradleLocalJavaHome">
5
+ <set>
6
+ <option value="$PROJECT_DIR$" />
7
+ </set>
8
+ </option>
9
+ </component>
10
+ </project>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ExternalStorageConfigurationManager" enabled="true" />
4
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
5
+ <output url="file://$PROJECT_DIR$/build/classes" />
6
+ </component>
7
+ <component name="ProjectType">
8
+ <option name="id" value="Android" />
9
+ </component>
10
+ </project>
@@ -0,0 +1,296 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="direct_access_persist.xml">
4
+ <option name="deviceSelectionList">
5
+ <list>
6
+ <PersistentDeviceSelectionData>
7
+ <option name="api" value="27" />
8
+ <option name="brand" value="DOCOMO" />
9
+ <option name="codename" value="F01L" />
10
+ <option name="id" value="F01L" />
11
+ <option name="manufacturer" value="FUJITSU" />
12
+ <option name="name" value="F-01L" />
13
+ <option name="screenDensity" value="360" />
14
+ <option name="screenX" value="720" />
15
+ <option name="screenY" value="1280" />
16
+ </PersistentDeviceSelectionData>
17
+ <PersistentDeviceSelectionData>
18
+ <option name="api" value="28" />
19
+ <option name="brand" value="DOCOMO" />
20
+ <option name="codename" value="SH-01L" />
21
+ <option name="id" value="SH-01L" />
22
+ <option name="manufacturer" value="SHARP" />
23
+ <option name="name" value="AQUOS sense2 SH-01L" />
24
+ <option name="screenDensity" value="480" />
25
+ <option name="screenX" value="1080" />
26
+ <option name="screenY" value="2160" />
27
+ </PersistentDeviceSelectionData>
28
+ <PersistentDeviceSelectionData>
29
+ <option name="api" value="31" />
30
+ <option name="brand" value="samsung" />
31
+ <option name="codename" value="a51" />
32
+ <option name="id" value="a51" />
33
+ <option name="manufacturer" value="Samsung" />
34
+ <option name="name" value="Galaxy A51" />
35
+ <option name="screenDensity" value="420" />
36
+ <option name="screenX" value="1080" />
37
+ <option name="screenY" value="2400" />
38
+ </PersistentDeviceSelectionData>
39
+ <PersistentDeviceSelectionData>
40
+ <option name="api" value="34" />
41
+ <option name="brand" value="google" />
42
+ <option name="codename" value="akita" />
43
+ <option name="id" value="akita" />
44
+ <option name="manufacturer" value="Google" />
45
+ <option name="name" value="Pixel 8a" />
46
+ <option name="screenDensity" value="420" />
47
+ <option name="screenX" value="1080" />
48
+ <option name="screenY" value="2400" />
49
+ </PersistentDeviceSelectionData>
50
+ <PersistentDeviceSelectionData>
51
+ <option name="api" value="33" />
52
+ <option name="brand" value="samsung" />
53
+ <option name="codename" value="b0q" />
54
+ <option name="id" value="b0q" />
55
+ <option name="manufacturer" value="Samsung" />
56
+ <option name="name" value="Galaxy S22 Ultra" />
57
+ <option name="screenDensity" value="600" />
58
+ <option name="screenX" value="1440" />
59
+ <option name="screenY" value="3088" />
60
+ </PersistentDeviceSelectionData>
61
+ <PersistentDeviceSelectionData>
62
+ <option name="api" value="32" />
63
+ <option name="brand" value="google" />
64
+ <option name="codename" value="bluejay" />
65
+ <option name="id" value="bluejay" />
66
+ <option name="manufacturer" value="Google" />
67
+ <option name="name" value="Pixel 6a" />
68
+ <option name="screenDensity" value="420" />
69
+ <option name="screenX" value="1080" />
70
+ <option name="screenY" value="2400" />
71
+ </PersistentDeviceSelectionData>
72
+ <PersistentDeviceSelectionData>
73
+ <option name="api" value="34" />
74
+ <option name="brand" value="google" />
75
+ <option name="codename" value="caiman" />
76
+ <option name="id" value="caiman" />
77
+ <option name="manufacturer" value="Google" />
78
+ <option name="name" value="Pixel 9 Pro" />
79
+ <option name="screenDensity" value="360" />
80
+ <option name="screenX" value="960" />
81
+ <option name="screenY" value="2142" />
82
+ </PersistentDeviceSelectionData>
83
+ <PersistentDeviceSelectionData>
84
+ <option name="api" value="34" />
85
+ <option name="brand" value="google" />
86
+ <option name="codename" value="comet" />
87
+ <option name="id" value="comet" />
88
+ <option name="manufacturer" value="Google" />
89
+ <option name="name" value="Pixel 9 Pro Fold" />
90
+ <option name="screenDensity" value="390" />
91
+ <option name="screenX" value="2076" />
92
+ <option name="screenY" value="2152" />
93
+ </PersistentDeviceSelectionData>
94
+ <PersistentDeviceSelectionData>
95
+ <option name="api" value="29" />
96
+ <option name="brand" value="samsung" />
97
+ <option name="codename" value="crownqlteue" />
98
+ <option name="id" value="crownqlteue" />
99
+ <option name="manufacturer" value="Samsung" />
100
+ <option name="name" value="Galaxy Note9" />
101
+ <option name="screenDensity" value="420" />
102
+ <option name="screenX" value="2220" />
103
+ <option name="screenY" value="1080" />
104
+ </PersistentDeviceSelectionData>
105
+ <PersistentDeviceSelectionData>
106
+ <option name="api" value="34" />
107
+ <option name="brand" value="samsung" />
108
+ <option name="codename" value="dm3q" />
109
+ <option name="id" value="dm3q" />
110
+ <option name="manufacturer" value="Samsung" />
111
+ <option name="name" value="Galaxy S23 Ultra" />
112
+ <option name="screenDensity" value="600" />
113
+ <option name="screenX" value="1440" />
114
+ <option name="screenY" value="3088" />
115
+ </PersistentDeviceSelectionData>
116
+ <PersistentDeviceSelectionData>
117
+ <option name="api" value="33" />
118
+ <option name="brand" value="google" />
119
+ <option name="codename" value="felix" />
120
+ <option name="id" value="felix" />
121
+ <option name="manufacturer" value="Google" />
122
+ <option name="name" value="Pixel Fold" />
123
+ <option name="screenDensity" value="420" />
124
+ <option name="screenX" value="2208" />
125
+ <option name="screenY" value="1840" />
126
+ </PersistentDeviceSelectionData>
127
+ <PersistentDeviceSelectionData>
128
+ <option name="api" value="33" />
129
+ <option name="brand" value="google" />
130
+ <option name="codename" value="felix_camera" />
131
+ <option name="id" value="felix_camera" />
132
+ <option name="manufacturer" value="Google" />
133
+ <option name="name" value="Pixel Fold (Camera-enabled)" />
134
+ <option name="screenDensity" value="420" />
135
+ <option name="screenX" value="2208" />
136
+ <option name="screenY" value="1840" />
137
+ </PersistentDeviceSelectionData>
138
+ <PersistentDeviceSelectionData>
139
+ <option name="api" value="33" />
140
+ <option name="brand" value="samsung" />
141
+ <option name="codename" value="gts8uwifi" />
142
+ <option name="id" value="gts8uwifi" />
143
+ <option name="manufacturer" value="Samsung" />
144
+ <option name="name" value="Galaxy Tab S8 Ultra" />
145
+ <option name="screenDensity" value="320" />
146
+ <option name="screenX" value="1848" />
147
+ <option name="screenY" value="2960" />
148
+ </PersistentDeviceSelectionData>
149
+ <PersistentDeviceSelectionData>
150
+ <option name="api" value="34" />
151
+ <option name="brand" value="google" />
152
+ <option name="codename" value="husky" />
153
+ <option name="id" value="husky" />
154
+ <option name="manufacturer" value="Google" />
155
+ <option name="name" value="Pixel 8 Pro" />
156
+ <option name="screenDensity" value="390" />
157
+ <option name="screenX" value="1008" />
158
+ <option name="screenY" value="2244" />
159
+ </PersistentDeviceSelectionData>
160
+ <PersistentDeviceSelectionData>
161
+ <option name="api" value="30" />
162
+ <option name="brand" value="motorola" />
163
+ <option name="codename" value="java" />
164
+ <option name="id" value="java" />
165
+ <option name="manufacturer" value="Motorola" />
166
+ <option name="name" value="G20" />
167
+ <option name="screenDensity" value="280" />
168
+ <option name="screenX" value="720" />
169
+ <option name="screenY" value="1600" />
170
+ </PersistentDeviceSelectionData>
171
+ <PersistentDeviceSelectionData>
172
+ <option name="api" value="34" />
173
+ <option name="brand" value="google" />
174
+ <option name="codename" value="komodo" />
175
+ <option name="id" value="komodo" />
176
+ <option name="manufacturer" value="Google" />
177
+ <option name="name" value="Pixel 9 Pro XL" />
178
+ <option name="screenDensity" value="360" />
179
+ <option name="screenX" value="1008" />
180
+ <option name="screenY" value="2244" />
181
+ </PersistentDeviceSelectionData>
182
+ <PersistentDeviceSelectionData>
183
+ <option name="api" value="33" />
184
+ <option name="brand" value="google" />
185
+ <option name="codename" value="lynx" />
186
+ <option name="id" value="lynx" />
187
+ <option name="manufacturer" value="Google" />
188
+ <option name="name" value="Pixel 7a" />
189
+ <option name="screenDensity" value="420" />
190
+ <option name="screenX" value="1080" />
191
+ <option name="screenY" value="2400" />
192
+ </PersistentDeviceSelectionData>
193
+ <PersistentDeviceSelectionData>
194
+ <option name="api" value="31" />
195
+ <option name="brand" value="google" />
196
+ <option name="codename" value="oriole" />
197
+ <option name="id" value="oriole" />
198
+ <option name="manufacturer" value="Google" />
199
+ <option name="name" value="Pixel 6" />
200
+ <option name="screenDensity" value="420" />
201
+ <option name="screenX" value="1080" />
202
+ <option name="screenY" value="2400" />
203
+ </PersistentDeviceSelectionData>
204
+ <PersistentDeviceSelectionData>
205
+ <option name="api" value="33" />
206
+ <option name="brand" value="google" />
207
+ <option name="codename" value="panther" />
208
+ <option name="id" value="panther" />
209
+ <option name="manufacturer" value="Google" />
210
+ <option name="name" value="Pixel 7" />
211
+ <option name="screenDensity" value="420" />
212
+ <option name="screenX" value="1080" />
213
+ <option name="screenY" value="2400" />
214
+ </PersistentDeviceSelectionData>
215
+ <PersistentDeviceSelectionData>
216
+ <option name="api" value="34" />
217
+ <option name="brand" value="samsung" />
218
+ <option name="codename" value="q5q" />
219
+ <option name="id" value="q5q" />
220
+ <option name="manufacturer" value="Samsung" />
221
+ <option name="name" value="Galaxy Z Fold5" />
222
+ <option name="screenDensity" value="420" />
223
+ <option name="screenX" value="1812" />
224
+ <option name="screenY" value="2176" />
225
+ </PersistentDeviceSelectionData>
226
+ <PersistentDeviceSelectionData>
227
+ <option name="api" value="30" />
228
+ <option name="brand" value="google" />
229
+ <option name="codename" value="r11" />
230
+ <option name="id" value="r11" />
231
+ <option name="manufacturer" value="Google" />
232
+ <option name="name" value="Pixel Watch" />
233
+ <option name="screenDensity" value="320" />
234
+ <option name="screenX" value="384" />
235
+ <option name="screenY" value="384" />
236
+ <option name="type" value="WEAR_OS" />
237
+ </PersistentDeviceSelectionData>
238
+ <PersistentDeviceSelectionData>
239
+ <option name="api" value="30" />
240
+ <option name="brand" value="google" />
241
+ <option name="codename" value="redfin" />
242
+ <option name="id" value="redfin" />
243
+ <option name="manufacturer" value="Google" />
244
+ <option name="name" value="Pixel 5" />
245
+ <option name="screenDensity" value="440" />
246
+ <option name="screenX" value="1080" />
247
+ <option name="screenY" value="2340" />
248
+ </PersistentDeviceSelectionData>
249
+ <PersistentDeviceSelectionData>
250
+ <option name="api" value="34" />
251
+ <option name="brand" value="google" />
252
+ <option name="codename" value="shiba" />
253
+ <option name="id" value="shiba" />
254
+ <option name="manufacturer" value="Google" />
255
+ <option name="name" value="Pixel 8" />
256
+ <option name="screenDensity" value="420" />
257
+ <option name="screenX" value="1080" />
258
+ <option name="screenY" value="2400" />
259
+ </PersistentDeviceSelectionData>
260
+ <PersistentDeviceSelectionData>
261
+ <option name="api" value="33" />
262
+ <option name="brand" value="google" />
263
+ <option name="codename" value="tangorpro" />
264
+ <option name="id" value="tangorpro" />
265
+ <option name="manufacturer" value="Google" />
266
+ <option name="name" value="Pixel Tablet" />
267
+ <option name="screenDensity" value="320" />
268
+ <option name="screenX" value="1600" />
269
+ <option name="screenY" value="2560" />
270
+ </PersistentDeviceSelectionData>
271
+ <PersistentDeviceSelectionData>
272
+ <option name="api" value="34" />
273
+ <option name="brand" value="google" />
274
+ <option name="codename" value="tokay" />
275
+ <option name="id" value="tokay" />
276
+ <option name="manufacturer" value="Google" />
277
+ <option name="name" value="Pixel 9" />
278
+ <option name="screenDensity" value="420" />
279
+ <option name="screenX" value="1080" />
280
+ <option name="screenY" value="2424" />
281
+ </PersistentDeviceSelectionData>
282
+ <PersistentDeviceSelectionData>
283
+ <option name="api" value="29" />
284
+ <option name="brand" value="samsung" />
285
+ <option name="codename" value="x1q" />
286
+ <option name="id" value="x1q" />
287
+ <option name="manufacturer" value="Samsung" />
288
+ <option name="name" value="Galaxy S20" />
289
+ <option name="screenDensity" value="480" />
290
+ <option name="screenX" value="1440" />
291
+ <option name="screenY" value="3200" />
292
+ </PersistentDeviceSelectionData>
293
+ </list>
294
+ </option>
295
+ </component>
296
+ </project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
5
+ </component>
6
+ </project>
@@ -61,7 +61,7 @@ repositories {
61
61
 
62
62
  dependencies {
63
63
  implementation fileTree(dir: "libs", include: ["*.jar"])
64
- implementation 'io.anyline:anylinesdk:53.3.0'
64
+ implementation 'io.anyline:anylinesdk:54.0.0'
65
65
  implementation "com.facebook.react:react-native:+"
66
66
  implementation("com.google.android.material:material:1.9.0")
67
67
  implementation 'androidx.multidex:multidex:2.0.1'
@@ -0,0 +1,8 @@
1
+ ## This file must *NOT* be checked into Version Control Systems,
2
+ # as it contains information specific to your local configuration.
3
+ #
4
+ # Location of the SDK. This is only used by Gradle.
5
+ # For customization when using a Version Control System, please read the
6
+ # header note.
7
+ #Mon Aug 26 14:06:49 IST 2024
8
+ sdk.dir=/Users/rohitlokhande/Library/Android/sdk
@@ -377,7 +377,7 @@ public class ScanActivity extends AppCompatActivity {
377
377
  resultObject.put("fullImagePath", fullImagePath);
378
378
  resultObject.put("imagePath", cutoutImagePath);
379
379
  } catch (Exception e) {
380
- e.printStackTrace();
380
+ finishWithError("Error save scan image: " + e.getMessage());
381
381
  }
382
382
  return resultObject;
383
383
  }
@@ -208,6 +208,9 @@ NSString * const ENABLE_NATIVE_BARCODE = @"nativeBarcodeScanningFormats";
208
208
  }
209
209
 
210
210
  + (UIColor *)colorFromHexString:(NSString *)hexString {
211
+ if (!hexString) {
212
+ return nil;
213
+ }
211
214
  unsigned rgbValue = 0;
212
215
  NSScanner *scanner = [NSScanner scannerWithString:hexString];
213
216
  // [scanner setScanLocation:1]; // bypass '#' character
@@ -39,8 +39,6 @@ typedef void (^ALPluginCallback)(NSDictionary * _Nullable callbackObj, NSError *
39
39
 
40
40
  + (NSError *)errorWithMessage:(NSString *)message;
41
41
 
42
- + (NSDate *)formattedStringToDate:(NSString *)formattedStr;
43
-
44
42
  + (NSString *)stringForDate:(NSDate *)date;
45
43
 
46
44
  + (NSString * _Nullable)confPropKeyWithScanModeForPluginConfig:(ALPluginConfig *)pluginConfig;
@@ -1,5 +1,5 @@
1
1
  #import "ALPluginHelper.h"
2
- #import "ALNFCScanViewController.h" // because NFC-specific code is there
2
+ #import "ALPluginScanViewController.h"
3
3
  #import <Anyline/Anyline.h>
4
4
  #import <objc/runtime.h>
5
5
 
@@ -11,60 +11,33 @@ NSErrorDomain const ALDefaultDomain = @"ALDefaultErrorDomain";
11
11
  #pragma mark - Launch Anyline
12
12
 
13
13
  + (void)startScan:(NSDictionary *)config initializationParamsStr:(NSString *)initializationParamsStr finished:(ALPluginCallback)callback {
14
-
14
+
15
15
  NSDictionary *pluginConf = config;
16
-
16
+
17
17
  NSString *licenseKey = [config objectForKey:@"licenseKey"];
18
-
18
+
19
19
  [[UIApplication sharedApplication] keyWindow].rootViewController.modalPresentationStyle = UIModalPresentationFullScreen;
20
-
20
+
21
21
  NSDictionary *optionsDict = [config objectForKey:@"options"];
22
22
  ALJSONUIConfiguration *jsonUIConf = [[ALJSONUIConfiguration alloc] initWithDictionary:optionsDict];
23
-
24
- BOOL isNFC = [optionsDict[@"enableNFCWithMRZ"] boolValue];
25
-
26
- if (isNFC) {
27
- if (@available(iOS 13.0, *)) {
28
-
29
- if (![ALNFCDetector readingAvailable]) {
30
- callback(nil, [NSError errorWithDomain:@"ALReactDomain" code:100 userInfo:@{NSLocalizedDescriptionKey: @"NFC passport reading is not supported on this device or app."}]);
31
-
32
- return;
33
- }
34
-
35
- ALNFCScanViewController *nfcScanViewController = [[ALNFCScanViewController alloc] initWithLicensekey:licenseKey
36
- configuration:pluginConf
37
- uiConfig:jsonUIConf
38
- initializationParamsStr:initializationParamsStr
39
- finished:callback];
40
- if (nfcScanViewController != nil) {
41
- [nfcScanViewController setModalPresentationStyle:UIModalPresentationFullScreen];
42
- [[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:nfcScanViewController
43
- animated:YES
44
- completion:nil];
45
- }
46
- } else {
47
- callback(nil,[NSError errorWithDomain:@"ALReactDomain" code:100 userInfo:@{NSLocalizedDescriptionKey: @"NFC passport reading is only supported on iOS 13 and later."}]);
48
- return;
49
- }
50
- } else {
51
- ALPluginScanViewController *pluginScanViewController = [[ALPluginScanViewController alloc] initWithLicensekey:licenseKey
52
- configuration:pluginConf
53
- uiConfiguration:jsonUIConf
54
- initializationParamsStr:initializationParamsStr
55
- finished:callback];
56
-
57
- if ([pluginConf valueForKey:@"quality"]){
58
- pluginScanViewController.quality = [[pluginConf valueForKey:@"quality"] integerValue];
59
- }
60
-
61
- if (pluginScanViewController) {
62
- [pluginScanViewController setModalPresentationStyle:UIModalPresentationFullScreen];
63
- [[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:pluginScanViewController
64
- animated:YES
65
- completion:nil];
66
- }
23
+
24
+ ALPluginScanViewController *pluginScanViewController = [[ALPluginScanViewController alloc] initWithLicensekey:licenseKey
25
+ configuration:pluginConf
26
+ uiConfiguration:jsonUIConf
27
+ initializationParamsStr:initializationParamsStr
28
+ finished:callback];
29
+
30
+ if ([pluginConf valueForKey:@"quality"]){
31
+ pluginScanViewController.quality = [[pluginConf valueForKey:@"quality"] integerValue];
67
32
  }
33
+
34
+ if (pluginScanViewController) {
35
+ [pluginScanViewController setModalPresentationStyle:UIModalPresentationFullScreen];
36
+ [[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:pluginScanViewController
37
+ animated:YES
38
+ completion:nil];
39
+ }
40
+
68
41
  }
69
42
 
70
43
  #pragma mark - Filesystem handling
@@ -307,16 +280,6 @@ NSErrorDomain const ALDefaultDomain = @"ALDefaultErrorDomain";
307
280
  }
308
281
 
309
282
  // MARK: - Date Utils
310
-
311
- + (NSDate *)formattedStringToDate:(NSString *)formattedStr {
312
- // From this: "Sun Apr 12 00:00:00 UTC 1977" to this: "04/12/1977"
313
- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
314
- [dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT+0:00"]];
315
- dateFormatter.dateFormat = @"E MMM d HH:mm:ss zzz yyyy";
316
- NSDate *d = [dateFormatter dateFromString:formattedStr];
317
- return d;
318
- }
319
-
320
283
  + (NSString *)stringForDate:(NSDate *)date {
321
284
  NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
322
285
  [dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT+0:00"]];
@@ -331,8 +294,11 @@ NSErrorDomain const ALDefaultDomain = @"ALDefaultErrorDomain";
331
294
  + (NSString * _Nullable)confPropKeyWithScanModeForPluginConfig:(ALPluginConfig *)pluginConfig {
332
295
  unsigned int count;
333
296
  Ivar *ivars = class_copyIvarList(ALPluginConfig.class, &count);
297
+ if (!ivars) {
298
+ return nil;
299
+ }
334
300
  for (int i = 0; i < count; i++) {
335
- const char *ivarName = ivar_getName(((Ivar * _Nonnull)ivars)[i]);
301
+ const char *ivarName = ivar_getName(ivars[i]);
336
302
  NSString *key = [NSString stringWithCString:(const char * _Nonnull)ivarName encoding:NSUTF8StringEncoding];
337
303
  key = [key stringByTrimmingCharactersInSet:NSCharacterSet.punctuationCharacterSet];
338
304
 
@@ -7,7 +7,7 @@ Pod::Spec.new do |s|
7
7
  s.version = package["version"]
8
8
  s.summary = "anyline-ocr-react-native-module"
9
9
  s.authors = {
10
- 'Aldrich Co' => 'aldrich.co@anyline.com'
10
+ 'Anyline GmbH' => 'capture-team@anyline.com'
11
11
  }
12
12
 
13
13
  s.homepage = "https://github.com/Anyline/anyline-ocr-react-native-module"
@@ -18,7 +18,7 @@ Pod::Spec.new do |s|
18
18
  s.source = { :git => "https://github.com/Anyline/anyline-ocr-react-native-module.git", :tag => "#{s.version}" }
19
19
 
20
20
  s.source_files = "*.{h,m}"
21
- s.dependency "Anyline", "53.3.0"
21
+ s.dependency "Anyline", "54.0.0"
22
22
  s.dependency "React"
23
23
 
24
24
  end
@@ -4,8 +4,6 @@
4
4
  #import "ALPluginScanViewController.h"
5
5
  #import "ALPluginHelper.h"
6
6
 
7
- #import "ALNFCScanViewController.h"
8
-
9
7
  ALWrapperConfig *wrapperConfig = nil;
10
8
 
11
9
  @interface AnylineSDKPlugin()
@@ -176,43 +174,18 @@ RCT_EXPORT_METHOD(exportCachedEvents:(RCTPromiseResolveBlock)resolve rejecter:(R
176
174
  [[UIApplication sharedApplication] keyWindow].rootViewController.modalPresentationStyle = UIModalPresentationFullScreen;
177
175
 
178
176
  if ([[scanMode uppercaseString] isEqualToString:[@"scan" uppercaseString]]) {
179
- BOOL isNFC = [optionsDictionary objectForKey:@"enableNFCWithMRZ"];
180
- if (isNFC) {
181
- if (@available(iOS 13.0, *)) {
182
- if ([ALNFCDetector readingAvailable]) {
183
- ALNFCScanViewController *nfcScanViewController = [[ALNFCScanViewController alloc] initWithLicensekey:self.appKey
184
- configuration:dictionary
185
- uiConfig:self.jsonUIConf
186
- initializationParamsStr:initializationParamsStr
187
- finished:^(NSDictionary * _Nullable callbackObj, NSError * _Nullable error) {
188
- [self returnCallback:callbackObj andError:error];
189
- }];
190
-
191
- if (nfcScanViewController != nil){
192
- [nfcScanViewController setModalPresentationStyle: UIModalPresentationFullScreen];
193
- [[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:nfcScanViewController animated:YES completion:nil];
194
- }
195
- } else {
196
- [self returnError:[NSError errorWithDomain:@"ALReactDomain" code:100 userInfo:@{NSLocalizedDescriptionKey: @"NFC passport reading is not supported on this device or app."}]];
197
- }
198
- } else {
199
- [self returnError:[NSError errorWithDomain:@"ALReactDomain" code:100 userInfo:@{NSLocalizedDescriptionKey: @"NFC passport reading is only supported on iOS 13 and later."}]];
200
-
201
- }
202
- } else {
203
- ALPluginScanViewController *pluginScanViewController =
204
- [[ALPluginScanViewController alloc] initWithLicensekey:self.appKey
205
- configuration:dictionary
206
- uiConfiguration:self.jsonUIConf
207
- initializationParamsStr:initializationParamsStr
208
- finished:^(NSDictionary * _Nullable callbackObj, NSError * _Nullable error) {
209
- [self returnCallback:callbackObj andError:error];
210
- }];
211
-
212
- if (pluginScanViewController != nil){
213
- [pluginScanViewController setModalPresentationStyle: UIModalPresentationFullScreen];
214
- [[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:pluginScanViewController animated:YES completion:nil];
215
- }
177
+ ALPluginScanViewController *pluginScanViewController =
178
+ [[ALPluginScanViewController alloc] initWithLicensekey:self.appKey
179
+ configuration:dictionary
180
+ uiConfiguration:self.jsonUIConf
181
+ initializationParamsStr:initializationParamsStr
182
+ finished:^(NSDictionary * _Nullable callbackObj, NSError * _Nullable error) {
183
+ [self returnCallback:callbackObj andError:error];
184
+ }];
185
+
186
+ if (pluginScanViewController != nil){
187
+ [pluginScanViewController setModalPresentationStyle: UIModalPresentationFullScreen];
188
+ [[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:pluginScanViewController animated:YES completion:nil];
216
189
  }
217
190
  } else {
218
191
  ALPluginScanViewController *pluginScanViewController =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "_from": "anyline-ocr-react-native-module@^53.3.0",
3
- "_id": "anyline-ocr-react-native-module@^53.3.0",
2
+ "_from": "anyline-ocr-react-native-module@^54.0.0",
3
+ "_id": "anyline-ocr-react-native-module@^54.0.0",
4
4
  "_inBundle": false,
5
5
  "_integrity": "sha512-BGi9zNkSsoxXywDBIqzgBRvKUBniQOJHDKBrozZubKthZNRBAj8Ry5tW0Me0yLXt/fauME//hbC0wsenfPJZqw==",
6
6
  "_location": "/anyline-ocr-react-native-module",
@@ -8,19 +8,19 @@
8
8
  "_requested": {
9
9
  "type": "range",
10
10
  "registry": true,
11
- "raw": "anyline-ocr-react-native-module@^53.3.0",
11
+ "raw": "anyline-ocr-react-native-module@^54.0.0",
12
12
  "name": "anyline-ocr-react-native-module",
13
13
  "escapedName": "anyline-ocr-react-native-module",
14
- "rawSpec": "^53.3.0",
14
+ "rawSpec": "^54.0.0",
15
15
  "saveSpec": null,
16
- "fetchSpec": "^53.3.0"
16
+ "fetchSpec": "^54.0.0"
17
17
  },
18
18
  "_requiredBy": [
19
19
  "/"
20
20
  ],
21
- "_resolved": "https://registry.npmjs.org/anyline-ocr-react-native-module/-/anyline-ocr-react-native-module-53.3.0.tgz",
21
+ "_resolved": "https://registry.npmjs.org/anyline-ocr-react-native-module/-/anyline-ocr-react-native-module-54.0.0.tgz",
22
22
  "_shasum": "bacbcd260cc662244f59393ed81a6edba009b52c",
23
- "_spec": "anyline-ocr-react-native-module@^53.3.0",
23
+ "_spec": "anyline-ocr-react-native-module@^54.0.0",
24
24
  "_where": "/Users/amiransari/Projects/anyline-ocr-react-native-module1/example/RNExampleApp",
25
25
  "bugs": {
26
26
  "url": "https://github.com/Anyline/anyline-ocr-react-native-module/issues"
@@ -47,5 +47,5 @@
47
47
  "type": "git",
48
48
  "url": "git+https://github.com/Anyline/anyline-ocr-react-native-module.git"
49
49
  },
50
- "version": "53.3.0"
50
+ "version": "54.0.0"
51
51
  }
@@ -1,15 +0,0 @@
1
- #import "ALPluginScanViewController.h"
2
- #import "ALJSONUIConfiguration.h"
3
-
4
- NS_ASSUME_NONNULL_BEGIN
5
-
6
- @interface ALNFCScanViewController : UIViewController
7
-
8
- - (instancetype)initWithLicensekey:(NSString *)licensekey
9
- configuration:(NSDictionary *)anylineConfig
10
- uiConfig:(ALJSONUIConfiguration *)uiConfig
11
- initializationParamsStr:(NSString *)initializationParamsStr
12
- finished:(ALPluginCallback)callback;
13
- @end
14
-
15
- NS_ASSUME_NONNULL_END
@@ -1,462 +0,0 @@
1
- #import <Anyline/Anyline.h>
2
- #import "ALNFCScanViewController.h"
3
- #import "ALPluginHelper.h"
4
- #import "AnylineSDKPlugin.h"
5
-
6
-
7
- API_AVAILABLE(ios(13.0))
8
- @interface ALNFCScanViewController () <ALNFCDetectorDelegate, ALScanPluginDelegate, ALScanViewDelegate>
9
-
10
- @property (nonatomic, strong) ALPluginCallback callback;
11
-
12
- @property (nonatomic, strong) NSDictionary *config;
13
-
14
- @property (nonatomic, copy) NSString *licenseKey;
15
-
16
- @property (nonatomic, strong) ALScanView *scanView;
17
-
18
- @property (nonatomic, strong) ALScanViewPlugin *mrzScanViewPlugin;
19
-
20
- @property (nonatomic, strong) ALNFCDetector *nfcDetector;
21
-
22
- // the result from NFC scanning is retained while NFC reading is initiated, and the results aggregated later
23
- @property (nonatomic, strong) NSMutableDictionary *resultDict;
24
-
25
- @property (nonatomic, strong) ALJSONUIConfiguration *uiConfig;
26
-
27
- @property (nonatomic, strong) UIView *hintView;
28
-
29
- @property (nonatomic, strong) UILabel *hintViewLabel;
30
-
31
- @property (nonatomic, strong) NSLayoutConstraint *labelHorizontalOffsetConstraint;
32
-
33
- @property (nonatomic, strong) NSLayoutConstraint *labelVerticalOffsetConstraint;
34
-
35
- @property (nonatomic, strong) UIButton *doneButton;
36
-
37
- // keep the last values we read from the MRZ so we can retry reading NFC
38
- // if NFC failed for reasons other than getting these details wrong
39
- @property (nonatomic, copy) NSString *passportNumberForNFC;
40
-
41
- @property (nonatomic, strong) NSDate *dateOfBirth;
42
-
43
- @property (nonatomic, strong) NSDate *dateOfExpiry;
44
-
45
- @property (nonatomic, strong) NSMutableArray<NSDictionary *> *detectedBarcodes;
46
-
47
- // JPEG compression quality 0-100
48
- @property (nonatomic, assign) NSUInteger quality;
49
-
50
- @property (nonatomic, nullable) NSString *initializationParamsStr;
51
-
52
- @end
53
-
54
-
55
- @implementation ALNFCScanViewController
56
-
57
- - (instancetype)initWithLicensekey:(NSString *)licensekey
58
- configuration:(NSDictionary *)anylineConfig
59
- uiConfig:(ALJSONUIConfiguration *)uiConfig
60
- initializationParamsStr:(NSString *)initializationParamsStr
61
- finished:(ALPluginCallback)callback {
62
- if (self = [super init]) {
63
- _licenseKey = licensekey;
64
- _callback = callback;
65
- _config = anylineConfig;
66
- _uiConfig = uiConfig;
67
- _initializationParamsStr = initializationParamsStr;
68
- self.quality = 90;
69
- }
70
- return self;
71
- }
72
-
73
- - (void)viewDidLoad {
74
- [super viewDidLoad];
75
-
76
- // NOTE: NFCDetector can throw an exception if the AnylineSDK isn't initialized
77
- // first as it will check the scope value of the license.
78
- //
79
- // If already initialized, happily move along. Otherwise, make a license key
80
- // check here.
81
- NSError *error;
82
- BOOL isInitialized = [ALLicenseUtil sharedInstance].isLicenseValid;
83
- if (!isInitialized) {
84
- [AnylineSDK setupWithLicenseKey:self.licenseKey cacheConfig:nil wrapperConfig:wrapperConfig error:&error];
85
- if ([self showErrorAlertIfNeeded:error]) {
86
- return;
87
- }
88
- }
89
-
90
- if (@available(iOS 13.0, *)) {
91
- self.nfcDetector = [self.class getNFCDetectorWithDelegate:self error:&error];
92
- } else {
93
- error = [ALPluginHelper errorWithMessage:@"iOS 13.0 or newer is required to scan with MRZ / NFC."];
94
- }
95
-
96
- if ([self showErrorAlertIfNeeded:error]) {
97
- return;
98
- }
99
-
100
- ALScanViewInitializationParameters *initializationParams = nil;
101
- if(_initializationParamsStr){
102
- initializationParams= [ALScanViewInitializationParameters withJSONString:_initializationParamsStr error:&error];
103
- }
104
-
105
- [self.view addSubview:self.scanView];
106
-
107
- self.resultDict = [[NSMutableDictionary alloc] init];
108
- self.detectedBarcodes = [NSMutableArray array];
109
-
110
- self.scanView = [ALScanViewFactory withJSONDictionary:self.config
111
- initializationParams:initializationParams
112
- delegate:self
113
- error:&error];
114
- self.scanView.delegate = self;
115
-
116
- [self configureMRZPlugin];
117
-
118
- if ([self showErrorAlertIfNeeded:error]) {
119
- return;
120
- }
121
-
122
- self.mrzScanViewPlugin = (ALScanViewPlugin *)self.scanView.viewPlugin;
123
-
124
- self.scanView.supportedNativeBarcodeFormats = self.uiConfig.nativeBarcodeFormats;
125
- self.scanView.delegate = self;
126
- self.detectedBarcodes = [NSMutableArray array];
127
-
128
- [self.view addSubview:self.scanView];
129
-
130
- self.scanView.translatesAutoresizingMaskIntoConstraints = false;
131
- [self.scanView.leftAnchor constraintEqualToAnchor:self.view.leftAnchor].active = YES;
132
- [self.scanView.rightAnchor constraintEqualToAnchor:self.view.rightAnchor].active = YES;
133
- [self.scanView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor].active = YES;
134
- [self.scanView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor].active = YES;
135
-
136
- [self.scanView startCamera];
137
-
138
- [self setupHintView];
139
-
140
- self.doneButton = [ALPluginHelper createButtonForViewController:self config:self.uiConfig];
141
- }
142
-
143
- - (void)viewDidAppear:(BOOL)animated {
144
- [super viewDidAppear:animated];
145
-
146
- NSError *error;
147
- [self startMRZScanning:&error];
148
- [self showErrorAlertIfNeeded:error];
149
- }
150
-
151
- - (void)viewDidDisappear:(BOOL)animated {
152
- [self stopMRZScanning];
153
- [super viewDidDisappear:animated];
154
- }
155
-
156
- - (void)startMRZScanning:(NSError **)error {
157
- [self.mrzScanViewPlugin startWithError:error];
158
- self.hintView.hidden = NO;
159
- }
160
-
161
- - (void)stopMRZScanning {
162
- [self.mrzScanViewPlugin stop];
163
- self.hintView.hidden = YES;
164
- }
165
-
166
- - (void)configureMRZPlugin {
167
-
168
- ALScanViewPlugin *scanViewPlugin = (ALScanViewPlugin *)self.scanView.viewPlugin;
169
- if (![scanViewPlugin isKindOfClass:ALScanViewPlugin.class]) {
170
- return;
171
- }
172
-
173
- ALCutoutConfig *cutoutConfig = scanViewPlugin.scanViewPluginConfig.cutoutConfig;
174
- ALScanFeedbackConfig *scanFeedbackConfig = scanViewPlugin.scanViewPluginConfig.scanFeedbackConfig;
175
-
176
- ALPluginConfig *pluginConfig = scanViewPlugin.scanPlugin.pluginConfig;
177
- ALMrzConfig *mrzConfig = pluginConfig.mrzConfig;
178
-
179
- // a bit lengthy but this is how you properly change the config (mrzFieldScanOptions and mrzMinFieldConfidences)
180
- // taking into account the readonly config fields
181
- mrzConfig.mrzFieldScanOptions = [[ALMrzFieldScanOptions alloc] init];
182
-
183
- mrzConfig.mrzFieldScanOptions.vizAddress = ALMrzScanOption.mrzScanOptionDefault;
184
- mrzConfig.mrzFieldScanOptions.vizDateOfIssue = ALMrzScanOption.mrzScanOptionDefault;
185
- mrzConfig.mrzFieldScanOptions.vizSurname = ALMrzScanOption.mrzScanOptionDefault;
186
- mrzConfig.mrzFieldScanOptions.vizGivenNames = ALMrzScanOption.mrzScanOptionDefault;
187
- mrzConfig.mrzFieldScanOptions.vizDateOfBirth = ALMrzScanOption.mrzScanOptionDefault;
188
- mrzConfig.mrzFieldScanOptions.vizDateOfExpiry = ALMrzScanOption.mrzScanOptionDefault;
189
-
190
- mrzConfig.mrzMinFieldConfidences = [[ALMrzMinFieldConfidences alloc] init];
191
- mrzConfig.mrzMinFieldConfidences.documentNumber = @(90);
192
- mrzConfig.mrzMinFieldConfidences.dateOfBirth = @(90);
193
- mrzConfig.mrzMinFieldConfidences.dateOfExpiry = @(90);
194
-
195
- NSError *error;
196
-
197
- ALViewPluginConfig *scanViewPluginConfig = scanViewPlugin.scanViewPluginConfig;
198
- [self.scanView setViewPluginConfig:scanViewPluginConfig error:&error];
199
-
200
- // the delegate binding was lost when you recreated the ScanPlugin it so you have to bring it back here
201
- scanViewPlugin = (ALScanViewPlugin *)self.scanView.viewPlugin;
202
- scanViewPlugin.scanPlugin.delegate = self;
203
- }
204
-
205
- // MARK: - ALIDPluginDelegate
206
-
207
- - (void)scanPlugin:(ALScanPlugin *)scanPlugin resultReceived:(ALScanResult *)scanResult {
208
-
209
- CGFloat compressionQuality = self.quality / 100.0f;
210
-
211
- // ACO just a failsafe for when cancelOnResult is not true
212
- [self stopMRZScanning];
213
-
214
- self.resultDict = [NSMutableDictionary dictionaryWithDictionary:scanResult.resultDictionary];
215
-
216
- NSString *imagePath = [ALPluginHelper saveImageToFileSystem:scanResult.croppedImage
217
- compressionQuality:compressionQuality];
218
- self.resultDict[@"imagePath"] = imagePath;
219
-
220
- imagePath = [ALPluginHelper saveImageToFileSystem:scanResult.fullSizeImage
221
- compressionQuality:compressionQuality];
222
-
223
- self.resultDict[@"fullImagePath"] = imagePath;
224
-
225
- ALMrzResult *MRZResult = scanResult.pluginResult.mrzResult;
226
- NSString *passportNumber = [MRZResult.documentNumber stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
227
-
228
- self.dateOfBirth = [ALPluginHelper formattedStringToDate:MRZResult.dateOfBirthObject];
229
-
230
- self.dateOfExpiry = [ALPluginHelper formattedStringToDate:MRZResult.dateOfExpiryObject];
231
-
232
- NSMutableString *passportNumberForNFC = [passportNumber mutableCopy];
233
- NSRange passportNumberRange = [MRZResult.mrzString rangeOfString:passportNumber];
234
- if (passportNumberRange.location != NSNotFound) {
235
- if ([MRZResult.mrzString characterAtIndex:NSMaxRange(passportNumberRange)] == '<') {
236
- [passportNumberForNFC appendString:@"<"];
237
- }
238
- }
239
-
240
- self.passportNumberForNFC = passportNumberForNFC;
241
-
242
- [self.nfcDetector startNfcDetectionWithPassportNumber:self.passportNumberForNFC
243
- dateOfBirth:self.dateOfBirth
244
- expirationDate:self.dateOfExpiry];
245
- }
246
-
247
- - (void)handleResult:(id _Nullable)resultObj {
248
-
249
- NSMutableDictionary *resultDictionary = [NSMutableDictionary dictionaryWithDictionary:resultObj];
250
- if (self.detectedBarcodes.count) {
251
- resultDictionary[@"nativeBarcodesDetected"] = self.detectedBarcodes;
252
- }
253
-
254
- NSObject<ALViewPluginBase> *scanViewPluginBase = self.scanView.viewPlugin;
255
- if ([scanViewPluginBase isKindOfClass:ALScanViewPlugin.class]) {
256
- ALScanViewPlugin *scanViewPlugin = (ALScanViewPlugin *)scanViewPluginBase;
257
- BOOL cancelOnResult = scanViewPlugin.scanPlugin.pluginConfig.cancelOnResult;
258
- if (cancelOnResult) {
259
- [self dismissViewControllerAnimated:YES completion:nil];
260
- }
261
- } else if ([scanViewPluginBase isKindOfClass:ALViewPluginComposite.class]) {
262
- // for composites, the cancelOnResult values for each child don't matter
263
- [self dismissViewControllerAnimated:YES completion:nil];
264
- }
265
- self.callback(resultDictionary, nil);
266
- }
267
-
268
- - (void)doneButtonPressed:(id)sender {
269
- [self stopMRZScanning];
270
-
271
- __weak __block typeof(self) weakSelf = self;
272
- [self dismissViewControllerAnimated:YES completion:^{
273
- weakSelf.callback(nil, @"Canceled");
274
- }];
275
- }
276
-
277
- // MARK: - ALNFCDetectorDelegate
278
-
279
- - (void)nfcSucceededWithResult:(ALNFCResult * _Nonnull)nfcResult API_AVAILABLE(ios(13.0)) {
280
-
281
- // DataGroup1
282
- NSMutableDictionary *dictResultDataGroup1 = [[NSMutableDictionary alloc] init];
283
-
284
-
285
- [dictResultDataGroup1 setValue:[ALPluginHelper stringForDate:nfcResult.dataGroup1.dateOfBirth]
286
- forKey:@"dateOfBirth"];
287
- [dictResultDataGroup1 setValue:[ALPluginHelper stringForDate:nfcResult.dataGroup1.dateOfExpiry]
288
- forKey:@"dateOfExpiry"];
289
- [dictResultDataGroup1 setValue:nfcResult.dataGroup1.documentNumber forKey:@"documentNumber"];
290
- [dictResultDataGroup1 setValue:nfcResult.dataGroup1.documentType forKey:@"documentType"];
291
- [dictResultDataGroup1 setValue:nfcResult.dataGroup1.firstName forKey:@"firstName"];
292
- [dictResultDataGroup1 setValue:nfcResult.dataGroup1.gender forKey:@"gender"];
293
- [dictResultDataGroup1 setValue:nfcResult.dataGroup1.issuingStateCode forKey:@"issuingStateCode"];
294
- [dictResultDataGroup1 setValue:nfcResult.dataGroup1.lastName forKey:@"lastName"];
295
- [dictResultDataGroup1 setValue:nfcResult.dataGroup1.nationality forKey:@"nationality"];
296
-
297
- [self.resultDict setObject:dictResultDataGroup1 forKey:@"dataGroup1"];
298
-
299
- // DataGroup2
300
- // ACO: we don't put the path into a separate 'dataGroup' category for the wrapper
301
- NSString *imagePath = [ALPluginHelper saveImageToFileSystem:nfcResult.dataGroup2.faceImage
302
- compressionQuality:self.quality / (CGFloat)100.0f];
303
- if (imagePath) {
304
- [self.resultDict setValue:imagePath forKey:@"imagePath"];
305
- }
306
-
307
- // SOD (Passport metadata)
308
- NSMutableDictionary *dictResultSOD = [[NSMutableDictionary alloc] init];
309
-
310
- [dictResultSOD setValue:nfcResult.sod.issuerCertificationAuthority forKey:@"issuerCertificationAuthority"];
311
- [dictResultSOD setValue:nfcResult.sod.issuerCountry forKey:@"issuerCountry"];
312
- [dictResultSOD setValue:nfcResult.sod.issuerOrganization forKey:@"issuerOrganization"];
313
- [dictResultSOD setValue:nfcResult.sod.issuerOrganizationalUnit forKey:@"issuerOrganizationalUnit"];
314
- [dictResultSOD setValue:nfcResult.sod.ldsHashAlgorithm forKey:@"ldsHashAlgorithm"];
315
-
316
- // ACO need to disable this because AppStoreConnect produces a warning with this enabled:
317
- // https://anyline.atlassian.net/browse/SDKY-1509?focusedCommentId=71554
318
- // [dictResultSOB setValue:nfcResult.sod.signatureAlgorithm forKey:@"signatureAlgorithm"];
319
-
320
- [dictResultSOD setValue:nfcResult.sod.validFromString forKey:@"validFromString"];
321
- [dictResultSOD setValue:nfcResult.sod.validUntilString forKey:@"validUntilString"];
322
-
323
- [self.resultDict setObject:dictResultSOD forKey:@"sod"];
324
-
325
- __weak __block typeof(self) weakSelf = self;
326
- dispatch_async(dispatch_get_main_queue(), ^{
327
- [weakSelf handleResult:weakSelf.resultDict];
328
- });
329
- }
330
-
331
- - (void)nfcFailedWithError:(NSError * _Nonnull)error {
332
- dispatch_async(dispatch_get_main_queue(), ^{
333
- if (error.code == ALNFCTagErrorNFCNotSupported) {
334
- [self showAlertWithTitle:@"NFC Not Supported"
335
- message:@"NFC passport reading is not supported on this device."];
336
- }
337
- if (error.code == ALNFCTagErrorResponseError || // MRZ key was likely wrong
338
- error.code == ALNFCTagErrorUnexpectedError) {
339
- // can mean the user pressed the 'Cancel' button while scanning, or the phone lost the
340
- // connection with the NFC chip because it was moved
341
- [self startMRZScanning:nil]; //run the MRZ scanner so we can try again.
342
- } else {
343
- // the MRZ details are correct, but something else went wrong. We can try reading
344
- // the NFC chip again without rescanning the MRZ.
345
- __weak __block typeof(self) weakSelf = self;
346
- dispatch_async(dispatch_get_main_queue(), ^{
347
- [weakSelf.nfcDetector startNfcDetectionWithPassportNumber:weakSelf.passportNumberForNFC
348
- dateOfBirth:weakSelf.dateOfBirth
349
- expirationDate:weakSelf.dateOfExpiry];
350
- });
351
- }
352
- });
353
- }
354
-
355
- // MARK: - ALScanViewDelegate
356
-
357
- - (void)scanView:(ALScanView *)scanView updatedCutoutWithPluginID:(NSString *)pluginID
358
- frame:(CGRect)frame {
359
-
360
- if (CGRectIsEmpty(frame)) {
361
- return;
362
- }
363
-
364
- self.hintView.hidden = NO;
365
-
366
- CGFloat xOffset = self.uiConfig.labelXPositionOffset;
367
- CGFloat yOffset = self.uiConfig.labelYPositionOffset;
368
-
369
- // takes into account that frame reported for a cutout is in relation to
370
- // its scan view's coordinate system
371
- yOffset += [self.scanView convertRect:frame toView:self.scanView.superview].origin.y;
372
-
373
- self.labelHorizontalOffsetConstraint.constant = xOffset;
374
- self.labelVerticalOffsetConstraint.constant = yOffset;
375
- }
376
-
377
- - (void)scanView:(ALScanView *)scanView didReceiveNativeBarcodeResult:(ALScanResult *)scanResult {
378
- // for this implementation we just take the last detected (we can show a list of it)
379
- [self.detectedBarcodes removeAllObjects];
380
- [self.detectedBarcodes addObject:scanResult.resultDictionary];
381
- }
382
-
383
-
384
- // MARK: - ALNFCDetector
385
-
386
- + (ALNFCDetector * _Nullable)getNFCDetectorWithDelegate:(id<ALNFCDetectorDelegate> _Nonnull)delegate
387
- error:(NSError * _Nullable * _Nullable)error API_AVAILABLE(ios(13.0)) {
388
- ALNFCDetector *NFCDetector;
389
- if (![ALNFCDetector readingAvailable]) {
390
- if (error) {
391
- *error = [ALPluginHelper errorWithMessage:@"NFC is not available for this device."];
392
- }
393
- return nil;
394
- }
395
- NFCDetector = [[ALNFCDetector alloc] initWithDelegate:delegate error:error];
396
- if (!NFCDetector) {
397
- return nil;
398
- }
399
- return NFCDetector;
400
- }
401
-
402
- // MARK: - Alerts
403
-
404
- - (void)showAlertWithTitle:(NSString *)title message:(NSString *)message {
405
- [ALPluginHelper showErrorAlertWithTitle:title message:message
406
- presentingViewController:self.navigationController];
407
- }
408
-
409
- - (BOOL)showErrorAlertIfNeeded:(NSError *)error {
410
- return [ALPluginHelper showErrorAlertIfNeeded:error pluginCallback:self.callback];
411
- }
412
-
413
- // MARK: - User Interface
414
-
415
- - (void)setupHintView {
416
-
417
- UIView *hintView = [[UIView alloc] initWithFrame:CGRectZero];
418
- hintView.layer.cornerRadius = 8;
419
- hintView.layer.masksToBounds = true;
420
- hintView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
421
-
422
- hintView.translatesAutoresizingMaskIntoConstraints = NO;
423
- [self.view addSubview:hintView];
424
-
425
- self.labelHorizontalOffsetConstraint = [hintView.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor constant:0];
426
-
427
- // at 0, the bottom of the label (container) should be touching the cutout top when the updatedCutoutRect report
428
- // is made
429
- self.labelVerticalOffsetConstraint = [hintView.bottomAnchor constraintEqualToAnchor:self.view.topAnchor constant:0];
430
-
431
- self.labelHorizontalOffsetConstraint.active = YES;
432
- self.labelVerticalOffsetConstraint.active = YES;
433
-
434
- UILabel *hintViewLabel = [[UILabel alloc] initWithFrame:CGRectZero];
435
-
436
- hintViewLabel.text = @"Scan MRZ";
437
- if (self.uiConfig.labelText.length) {
438
- hintViewLabel.text = self.uiConfig.labelText;
439
- }
440
-
441
- hintViewLabel.font = [UIFont fontWithName:@"HelveticaNeue"
442
- size:self.uiConfig.labelSize];
443
- hintViewLabel.textColor = self.uiConfig.labelColor;
444
- hintViewLabel.textAlignment = NSTextAlignmentCenter;
445
- hintViewLabel.translatesAutoresizingMaskIntoConstraints = NO;
446
- [hintViewLabel sizeToFit];
447
- [hintView addSubview:hintViewLabel];
448
-
449
- [hintViewLabel.centerXAnchor constraintEqualToAnchor:hintView.centerXAnchor].active = YES;
450
- [hintViewLabel.centerYAnchor constraintEqualToAnchor:hintView.centerYAnchor].active = YES;
451
-
452
- NSLayoutConstraint *cnst = [hintView.widthAnchor constraintGreaterThanOrEqualToAnchor:hintViewLabel.widthAnchor
453
- constant:20];
454
- cnst.active = YES;
455
- cnst = [hintView.heightAnchor constraintEqualToAnchor:hintViewLabel.heightAnchor constant:20];
456
- cnst.active = YES;
457
-
458
- self.hintView = hintView;
459
- self.hintViewLabel = hintViewLabel;
460
- }
461
-
462
- @end