@regulaforensics/react-native-document-reader-api 7.4.735 → 7.5.85-rc
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.
- package/README.md +1 -1
- package/RNDocumentReaderApi.podspec +2 -2
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/regula/documentreader/BluetoothUtil.kt +105 -59
- package/android/src/main/java/com/regula/documentreader/Config.kt +63 -5
- package/android/src/main/java/com/regula/documentreader/JSONConstructor.kt +39 -14
- package/android/src/main/java/com/regula/documentreader/RNRegulaDocumentReaderModule.kt +75 -61
- package/android/src/main/java/com/regula/documentreader/Utils.kt +7 -2
- package/example/App.tsx +5 -0
- package/example/android/app/src/main/AndroidManifest.xml +1 -0
- package/example/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/example/ios/DocumentReader/Info.plist +0 -2
- package/example/ios/DocumentReader.xcodeproj/project.pbxproj +4 -4
- package/example/ios/Podfile +2 -0
- package/example/package-lock.json +5794 -6178
- package/example/package.json +6 -7
- package/index.d.ts +113 -9
- package/index.js +81 -6
- package/ios/RGLWConfig.h +2 -0
- package/ios/RGLWConfig.m +103 -50
- package/ios/RGLWJSONConstructor.h +8 -0
- package/ios/RGLWJSONConstructor.m +77 -9
- package/ios/RNRegulaDocumentReader.h +4 -1
- package/ios/RNRegulaDocumentReader.m +71 -24
- package/package.json +2 -6
- package/.github/ISSUE_TEMPLATE/config.yml +0 -5
|
@@ -11,6 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
@implementation RGLWJSONConstructor
|
|
13
13
|
|
|
14
|
+
static NSMutableArray* weakReferencesHolder;
|
|
15
|
+
+(void) holdWeakReference:(id)reference {
|
|
16
|
+
if(!weakReferencesHolder)
|
|
17
|
+
weakReferencesHolder = [NSMutableArray new];
|
|
18
|
+
[weakReferencesHolder addObject:reference];
|
|
19
|
+
}
|
|
20
|
+
|
|
14
21
|
+(NSString*)dictToString:(NSDictionary*)input {
|
|
15
22
|
if(input == nil) return nil;
|
|
16
23
|
return [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:input options:NSJSONWritingPrettyPrinted error:nil] encoding:NSUTF8StringEncoding];
|
|
@@ -23,6 +30,7 @@
|
|
|
23
30
|
|
|
24
31
|
+(NSData*)base64Decode:(NSString*)input {
|
|
25
32
|
if(input == nil) return nil;
|
|
33
|
+
if ([input hasPrefix:@"data"]) input = [input substringFromIndex:[input rangeOfString:@","].location + 1];
|
|
26
34
|
return [[NSData alloc] initWithBase64EncodedString:input options:0];
|
|
27
35
|
}
|
|
28
36
|
|
|
@@ -103,8 +111,9 @@
|
|
|
103
111
|
|
|
104
112
|
NSString* transactionId = [input valueForKey:@"transactionId"];
|
|
105
113
|
NSString* tag = [input valueForKey:@"tag"];
|
|
114
|
+
NSString* sessionLogFolder = input[@"sessionLogFolder"];
|
|
106
115
|
|
|
107
|
-
return [[RGLTransactionInfo alloc] initWithTag:tag transactionId:transactionId];
|
|
116
|
+
return [[RGLTransactionInfo alloc] initWithTag:tag transactionId:transactionId sessionLogFolder:sessionLogFolder];
|
|
108
117
|
}
|
|
109
118
|
|
|
110
119
|
+(NSDictionary*)generateTransactionInfo:(RGLTransactionInfo*)input {
|
|
@@ -113,6 +122,7 @@
|
|
|
113
122
|
|
|
114
123
|
result[@"transactionId"] = input.transactionId;
|
|
115
124
|
result[@"tag"] = input.tag;
|
|
125
|
+
result[@"sessionLogFolder"] = input.sessionLogFolder;
|
|
116
126
|
|
|
117
127
|
return result;
|
|
118
128
|
}
|
|
@@ -166,6 +176,17 @@
|
|
|
166
176
|
return result;
|
|
167
177
|
}
|
|
168
178
|
|
|
179
|
+
+(RGLBleConfig*)bleDeviceConfigFromJson:(NSDictionary*)input :(RGLBluetooth*)bluetooth {
|
|
180
|
+
if (!input) return nil;
|
|
181
|
+
RGLBleConfig *config = [[RGLBleConfig alloc] initWithBluetooth:bluetooth];
|
|
182
|
+
|
|
183
|
+
if (input[@"databasePath"]) config.databasePath = [[NSBundle mainBundle] pathForResource:input[@"databasePath"] ofType:nil];
|
|
184
|
+
if (input[@"licenseUpdate"]) config.licenseUpdateCheck = [input[@"licenseUpdate"] boolValue];
|
|
185
|
+
if (input[@"delayedNNLoad"]) config.delayedNNLoadEnabled = [input[@"delayedNNLoad"] boolValue];
|
|
186
|
+
|
|
187
|
+
return config;
|
|
188
|
+
}
|
|
189
|
+
|
|
169
190
|
+(RGLScannerConfig*)scannerConfigFromJson:(NSDictionary*)input {
|
|
170
191
|
RGLScannerConfig *config = [RGLScannerConfig alloc];
|
|
171
192
|
if (input[@"scenario"]) config = [config initWithScenario:input[@"scenario"]];
|
|
@@ -216,7 +237,8 @@
|
|
|
216
237
|
if (input[@"scenario"]) config.scenario = input[@"scenario"];
|
|
217
238
|
if (input[@"livePortrait"]) config.livePortrait = [self imageWithBase64:input[@"livePortrait"]];
|
|
218
239
|
if (input[@"extPortrait"]) config.extPortrait = [self imageWithBase64:input[@"extPortrait"]];
|
|
219
|
-
if (input[@"oneShotIdentification"])
|
|
240
|
+
if (input[@"oneShotIdentification"]) config.oneShotIdentification = input[@"oneShotIdentification"];
|
|
241
|
+
if (input[@"dtc"]) config.dtc = [RGLWJSONConstructor base64Decode:input[@"dtc"]];
|
|
220
242
|
|
|
221
243
|
return config;
|
|
222
244
|
}
|
|
@@ -230,6 +252,7 @@
|
|
|
230
252
|
result[@"livePortrait"] = [self base64WithImage: input.livePortrait];
|
|
231
253
|
result[@"extPortrait"] = [self base64WithImage: input.extPortrait];
|
|
232
254
|
result[@"oneShotIdentification"] = @(input.oneShotIdentification);
|
|
255
|
+
result[@"dtc"] = [self base64Encode: input.dtc];
|
|
233
256
|
result[@"image"] = [self base64WithImage: input.image];
|
|
234
257
|
result[@"data"] = [self base64Encode: input.imageData];
|
|
235
258
|
if(input.images != nil) {
|
|
@@ -258,6 +281,7 @@
|
|
|
258
281
|
result.httpHeaders = [input valueForKey:@"httpHeaders"];
|
|
259
282
|
if([input valueForKey:@"rfidServerSideChipVerification"] != nil)
|
|
260
283
|
result.rfidServerSideChipVerification = [input valueForKey:@"rfidServerSideChipVerification"];
|
|
284
|
+
if (input[@"timeoutConnection"]) result.timeoutConnection = input[@"timeoutConnection"];
|
|
261
285
|
|
|
262
286
|
return result;
|
|
263
287
|
}
|
|
@@ -269,6 +293,7 @@
|
|
|
269
293
|
result[@"url"] = input.url;
|
|
270
294
|
result[@"httpHeaders"] = input.httpHeaders;
|
|
271
295
|
result[@"rfidServerSideChipVerification"] = input.rfidServerSideChipVerification;
|
|
296
|
+
result[@"timeoutConnection"] = input.timeoutConnection;
|
|
272
297
|
|
|
273
298
|
return result;
|
|
274
299
|
}
|
|
@@ -333,6 +358,16 @@
|
|
|
333
358
|
return [RGLWConfig getDataGroups:input];
|
|
334
359
|
}
|
|
335
360
|
|
|
361
|
+
+(RGLDTCDataGroup*)dtcDataGroupFromJson:(NSDictionary*)input {
|
|
362
|
+
RGLDTCDataGroup *result = [RGLDTCDataGroup new];
|
|
363
|
+
[RGLWConfig setDTCDataGroup:result dict:input];
|
|
364
|
+
return result;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
+(NSDictionary*)generateRGLDTCDataGroup:(RGLDTCDataGroup*)input {
|
|
368
|
+
return [RGLWConfig getDTCDataGroup:input];
|
|
369
|
+
}
|
|
370
|
+
|
|
336
371
|
+(RGLRFIDScenario*)rfidScenarioFromJson:(NSDictionary*)input {
|
|
337
372
|
RGLRFIDScenario *result = [RGLRFIDScenario new];
|
|
338
373
|
[RGLWConfig setRfidScenario:input :result];
|
|
@@ -380,6 +415,11 @@
|
|
|
380
415
|
[RGLWConfig setProcessParams:[input valueForKey:@"processParams"] :params];
|
|
381
416
|
result.processParams = params;
|
|
382
417
|
}
|
|
418
|
+
if([input valueForKey:@"requestHeaders"] != nil) {
|
|
419
|
+
RGLWRequestInterceptorProxy* proxy = [[RGLWRequestInterceptorProxy alloc] initWithHeaders:[input valueForKey:@"requestHeaders"]];
|
|
420
|
+
[self holdWeakReference: proxy];
|
|
421
|
+
result.requestInterceptingDelegate = proxy;
|
|
422
|
+
}
|
|
383
423
|
|
|
384
424
|
return result;
|
|
385
425
|
}
|
|
@@ -1658,10 +1698,12 @@
|
|
|
1658
1698
|
NSMutableArray<RGLAuthenticityElement*> *array = [NSMutableArray new];
|
|
1659
1699
|
for(NSDictionary* item in [input valueForKey:@"elements"])
|
|
1660
1700
|
[array addObject:[self authenticityElementFromJson:item]];
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1701
|
+
RGLAuthenticityCheck* result = [[RGLAuthenticityCheck alloc]
|
|
1702
|
+
initWithAuthenticity:[[input valueForKey:@"type"] integerValue]
|
|
1703
|
+
elements:array
|
|
1704
|
+
pageIndex:[[input valueForKey:@"pageIndex"] integerValue]];
|
|
1705
|
+
if (input[@"status"]) [result setValue:input[@"status"] forKey:@"status"];
|
|
1706
|
+
return result;;
|
|
1665
1707
|
}
|
|
1666
1708
|
|
|
1667
1709
|
+(NSDictionary*)generateAuthenticityCheck:(RGLAuthenticityCheck*)input {
|
|
@@ -1764,8 +1806,10 @@
|
|
|
1764
1806
|
NSMutableArray<RGLAuthenticityCheck*> *array = [NSMutableArray new];
|
|
1765
1807
|
for(NSDictionary* item in [input valueForKey:@"checks"])
|
|
1766
1808
|
[array addObject:[self authenticityCheckFromJson:item]];
|
|
1767
|
-
|
|
1768
|
-
|
|
1809
|
+
RGLDocumentReaderAuthenticityResult* result = [[RGLDocumentReaderAuthenticityResult alloc]
|
|
1810
|
+
initWithAuthenticityChecks:array];
|
|
1811
|
+
if (input[@"status"]) [result setValue:input[@"status"] forKey:@"_security"];
|
|
1812
|
+
return result;
|
|
1769
1813
|
}
|
|
1770
1814
|
|
|
1771
1815
|
+(NSDictionary*)generateDocumentReaderAuthenticityResult:(RGLDocumentReaderAuthenticityResult*)input {
|
|
@@ -2220,7 +2264,7 @@
|
|
|
2220
2264
|
[imageQuality addObject:[self imageQualityGroupFromJson:item]];
|
|
2221
2265
|
}
|
|
2222
2266
|
|
|
2223
|
-
|
|
2267
|
+
RGLDocumentReaderResults* result = [[RGLDocumentReaderResults alloc]
|
|
2224
2268
|
initWithDocumentTypes:documentType
|
|
2225
2269
|
textResult:[self documentReaderTextResultFromJson: [input valueForKey:@"textResult"]]
|
|
2226
2270
|
graphicResult:[self documentReaderGraphicResultFromJson: [input valueForKey:@"graphicResult"]]
|
|
@@ -2240,6 +2284,10 @@
|
|
|
2240
2284
|
elapsedTime:[[input valueForKey:@"elapsedTime"] integerValue]
|
|
2241
2285
|
elapsedTimeRFID:[[input valueForKey:@"elapsedTimeRFID"] integerValue]
|
|
2242
2286
|
transactionInfo:[self transactionInfoFromJson:[input valueForKey:@"transactionInfo"]]];
|
|
2287
|
+
|
|
2288
|
+
[result setValue:[RGLWJSONConstructor base64Decode:input[@"dtcData"]] forKey:@"dtcData"];
|
|
2289
|
+
|
|
2290
|
+
return result;
|
|
2243
2291
|
}
|
|
2244
2292
|
|
|
2245
2293
|
+(NSDictionary*)generateDocumentReaderResults:(RGLDocumentReaderResults*)input {
|
|
@@ -2289,6 +2337,7 @@
|
|
|
2289
2337
|
result[@"rawResult"] = input.rawResult;
|
|
2290
2338
|
result[@"status"] = [self generateDocumentReaderResultsStatus:input.status];
|
|
2291
2339
|
result[@"vdsncData"] = [self generateVDSNCData:input.vdsncData];
|
|
2340
|
+
result[@"dtcData"] = [self base64Encode: input.dtcData];
|
|
2292
2341
|
result[@"transactionInfo"] = [self generateTransactionInfo:input.transactionInfo];
|
|
2293
2342
|
|
|
2294
2343
|
return result;
|
|
@@ -2305,3 +2354,22 @@
|
|
|
2305
2354
|
}
|
|
2306
2355
|
|
|
2307
2356
|
@end
|
|
2357
|
+
|
|
2358
|
+
@implementation RGLWRequestInterceptorProxy {
|
|
2359
|
+
NSDictionary* _headers;
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
- (instancetype)initWithHeaders:(NSDictionary*)headers {
|
|
2363
|
+
self = [super init];
|
|
2364
|
+
_headers = [headers copy];
|
|
2365
|
+
return self;
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
-(NSURLRequest*)interceptorPrepareRequest:(NSURLRequest*)request {
|
|
2369
|
+
NSMutableURLRequest *interceptedRequest = [request mutableCopy];
|
|
2370
|
+
for (NSString* key in _headers.allKeys)
|
|
2371
|
+
[interceptedRequest addValue:[_headers valueForKey:key] forHTTPHeaderField:key];
|
|
2372
|
+
return interceptedRequest;
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
@end
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#import <React/RCTBridgeModule.h>
|
|
2
2
|
#import <React/RCTEventEmitter.h>
|
|
3
|
+
#import <CoreBluetooth/CoreBluetooth.h>
|
|
3
4
|
#import <DocumentReader/DocumentReader.h>
|
|
4
5
|
#import "RGLWJSONConstructor.h"
|
|
5
6
|
#import "RGLWConfig.h"
|
|
@@ -12,7 +13,9 @@ typedef void (^RGLWRFIDSignatureCallback)(NSData * _Nonnull signature);
|
|
|
12
13
|
RGLRecordScanningProcessDelegate,
|
|
13
14
|
RGLDocReaderRFIDDelegate,
|
|
14
15
|
RGLCustomizationActionDelegate,
|
|
15
|
-
RGLDocReaderDatabaseFetchDelegate
|
|
16
|
+
RGLDocReaderDatabaseFetchDelegate,
|
|
17
|
+
RGLBluetoothDelegate,
|
|
18
|
+
CBCentralManagerDelegate>
|
|
16
19
|
|
|
17
20
|
@property NSNumber* _Nonnull doRequestPACertificates;
|
|
18
21
|
@property NSNumber* _Nonnull doRequestTACertificates;
|
|
@@ -17,9 +17,6 @@ RCT_EXPORT_MODULE();
|
|
|
17
17
|
RGLWPaCertificateCompletionEvent,
|
|
18
18
|
RGLWTaCertificateCompletionEvent,
|
|
19
19
|
RGLWTaSignatureCompletionEvent,
|
|
20
|
-
RGLWBleOnServiceConnectedEvent,
|
|
21
|
-
RGLWBleOnServiceDisconnectedEvent,
|
|
22
|
-
RGLWBleOnDeviceReadyEvent,
|
|
23
20
|
RGLWOnCustomButtonTappedEvent];
|
|
24
21
|
}
|
|
25
22
|
|
|
@@ -49,10 +46,6 @@ RCT_EXPORT_METHOD(exec:(NSString*)moduleName:(NSString*)action:(NSArray*)args:(R
|
|
|
49
46
|
[self getDocumentReaderIsReady :successCallback :errorCallback];
|
|
50
47
|
else if([action isEqualToString:@"getDocumentReaderStatus"])
|
|
51
48
|
[self getDocumentReaderStatus :successCallback :errorCallback];
|
|
52
|
-
else if([action isEqualToString:@"isAuthenticatorAvailableForUse"])
|
|
53
|
-
[self isAuthenticatorAvailableForUse :successCallback :errorCallback];
|
|
54
|
-
else if([action isEqualToString:@"isBlePermissionsGranted"])
|
|
55
|
-
[self isBlePermissionsGranted :successCallback :errorCallback];
|
|
56
49
|
else if([action isEqualToString:@"getRfidSessionStatus"])
|
|
57
50
|
[self getRfidSessionStatus :successCallback :errorCallback];
|
|
58
51
|
else if([action isEqualToString:@"setRfidSessionStatus"])
|
|
@@ -131,8 +124,8 @@ RCT_EXPORT_METHOD(exec:(NSString*)moduleName:(NSString*)action:(NSArray*)args:(R
|
|
|
131
124
|
[self clearPKDCertificates :successCallback :errorCallback];
|
|
132
125
|
else if([action isEqualToString:@"startNewSession"])
|
|
133
126
|
[self startNewSession :successCallback :errorCallback];
|
|
134
|
-
else if([action isEqualToString:@"
|
|
135
|
-
[self
|
|
127
|
+
else if([action isEqualToString:@"connectBluetoothDevice"])
|
|
128
|
+
[self connectBluetoothDevice :[args objectAtIndex:0] :successCallback :errorCallback];
|
|
136
129
|
else if([action isEqualToString:@"setLocalizationDictionary"])
|
|
137
130
|
[self setLocalizationDictionary :[args objectAtIndex:0] :successCallback :errorCallback];
|
|
138
131
|
else if([action isEqualToString:@"getLicense"])
|
|
@@ -141,6 +134,10 @@ RCT_EXPORT_METHOD(exec:(NSString*)moduleName:(NSString*)action:(NSArray*)args:(R
|
|
|
141
134
|
[self getAvailableScenarios :successCallback :errorCallback];
|
|
142
135
|
else if([action isEqualToString:@"getIsRFIDAvailableForUse"])
|
|
143
136
|
[self getIsRFIDAvailableForUse :successCallback :errorCallback];
|
|
137
|
+
else if([action isEqualToString:@"isAuthenticatorRFIDAvailableForUse"])
|
|
138
|
+
[self isAuthenticatorRFIDAvailableForUse :successCallback :errorCallback];
|
|
139
|
+
else if([action isEqualToString:@"isAuthenticatorAvailableForUse"])
|
|
140
|
+
[self isAuthenticatorAvailableForUse :successCallback :errorCallback];
|
|
144
141
|
else if([action isEqualToString:@"getDocReaderVersion"])
|
|
145
142
|
[self getDocReaderVersion :successCallback :errorCallback];
|
|
146
143
|
else if([action isEqualToString:@"getDocReaderDocumentsDatabase"])
|
|
@@ -181,6 +178,8 @@ RCT_EXPORT_METHOD(exec:(NSString*)moduleName:(NSString*)action:(NSArray*)args:(R
|
|
|
181
178
|
[self encryptedContainers :[args objectAtIndex:0] :successCallback :errorCallback];
|
|
182
179
|
else if([action isEqualToString:@"finalizePackage"])
|
|
183
180
|
[self finalizePackage :successCallback :errorCallback];
|
|
181
|
+
else if([action isEqualToString:@"endBackendTransaction"])
|
|
182
|
+
[self endBackendTransaction :successCallback :errorCallback];
|
|
184
183
|
else if([action isEqualToString:@"getTranslation"])
|
|
185
184
|
[self getTranslation :[args objectAtIndex:0] :[args objectAtIndex:1] :successCallback :errorCallback];
|
|
186
185
|
else
|
|
@@ -198,10 +197,6 @@ NSString* RGLWPaCertificateCompletionEvent = @"pa_certificate_completion";
|
|
|
198
197
|
NSString* RGLWTaCertificateCompletionEvent = @"ta_certificate_completion";
|
|
199
198
|
NSString* RGLWTaSignatureCompletionEvent = @"ta_signature_completion";
|
|
200
199
|
|
|
201
|
-
NSString* RGLWBleOnServiceConnectedEvent = @"bleOnServiceConnectedEvent";
|
|
202
|
-
NSString* RGLWBleOnServiceDisconnectedEvent = @"bleOnServiceDisconnectedEvent";
|
|
203
|
-
NSString* RGLWBleOnDeviceReadyEvent = @"bleOnDeviceReadyEvent";
|
|
204
|
-
|
|
205
200
|
NSString* RGLWVideoEncoderCompletionEvent = @"video_encoder_completion";
|
|
206
201
|
NSString* RGLWOnCustomButtonTappedEvent = @"onCustomButtonTappedEvent";
|
|
207
202
|
|
|
@@ -213,14 +208,6 @@ NSString* RGLWOnCustomButtonTappedEvent = @"onCustomButtonTappedEvent";
|
|
|
213
208
|
successCallback(RGLDocReader.shared.documentReaderStatus);
|
|
214
209
|
}
|
|
215
210
|
|
|
216
|
-
- (void) isAuthenticatorAvailableForUse:(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
|
|
217
|
-
successCallback(RGLDocReader.shared.isAuthenticatorAvailableForUse ? @YES : @NO);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
- (void) isBlePermissionsGranted:(RGLWCallback)successCallback :(RGLWCallback)errorCallback {
|
|
221
|
-
errorCallback(@"isBlePermissionsGranted() is an android-only method");
|
|
222
|
-
}
|
|
223
|
-
|
|
224
211
|
- (void) getRfidSessionStatus:(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
|
|
225
212
|
successCallback(RGLDocReader.shared.rfidSessionStatus);
|
|
226
213
|
}
|
|
@@ -300,7 +287,7 @@ NSString* RGLWOnCustomButtonTappedEvent = @"onCustomButtonTappedEvent";
|
|
|
300
287
|
}
|
|
301
288
|
|
|
302
289
|
- (void) initializeReaderWithBleDeviceConfig:(NSDictionary*)config :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
|
|
303
|
-
|
|
290
|
+
[RGLDocReader.shared initializeReaderWithConfig:[RGLWJSONConstructor bleDeviceConfigFromJson:config :bluetooth] completion:[self getInitCompletion :successCallback :errorCallback]];
|
|
304
291
|
}
|
|
305
292
|
|
|
306
293
|
- (void) deinitializeReader:(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
|
|
@@ -444,8 +431,55 @@ NSString* RGLWOnCustomButtonTappedEvent = @"onCustomButtonTappedEvent";
|
|
|
444
431
|
successCallback(@"");
|
|
445
432
|
}
|
|
446
433
|
|
|
447
|
-
|
|
448
|
-
|
|
434
|
+
RGLBluetooth* bluetooth;
|
|
435
|
+
CBCentralManager* centralManager;
|
|
436
|
+
RGLWCallback savedCallbackForBluetoothResult;
|
|
437
|
+
|
|
438
|
+
- (void) connectBluetoothDevice:(NSString*)deviceName :(RGLWCallback)successCallback :(RGLWCallback)errorCallback {
|
|
439
|
+
// register callback for user's answer to bluetooth permission
|
|
440
|
+
centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
|
|
441
|
+
|
|
442
|
+
// return if already connected
|
|
443
|
+
if (bluetooth && bluetooth.state == RGLBluetoothConnectionStateConnected) return;
|
|
444
|
+
|
|
445
|
+
// start searching devices
|
|
446
|
+
if (!bluetooth) {
|
|
447
|
+
bluetooth = [RGLBluetooth new];
|
|
448
|
+
bluetooth.delegate = self;
|
|
449
|
+
}
|
|
450
|
+
savedCallbackForBluetoothResult = successCallback;
|
|
451
|
+
[bluetooth connectWithDeviceName:deviceName];
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// CBCentralManagerDelegate
|
|
455
|
+
- (void)centralManagerDidUpdateState:(CBCentralManager *)central {
|
|
456
|
+
if (central.state != CBManagerStatePoweredOn && savedCallbackForBluetoothResult)
|
|
457
|
+
[self bluetoothDeviceConnectionFailed];
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// RGLBluetoothDelegate
|
|
461
|
+
- (void)didChangeConnectionState:(RGLBluetooth *)bluetooth state:(RGLBluetoothConnectionState)state {
|
|
462
|
+
if (state == RGLBluetoothConnectionStateNone && savedCallbackForBluetoothResult)
|
|
463
|
+
[self bluetoothDeviceConnectionFailed];
|
|
464
|
+
|
|
465
|
+
// set searching timeout
|
|
466
|
+
if (state == RGLBluetoothConnectionStateSearching)
|
|
467
|
+
[self performSelector:NSSelectorFromString(@"bluetoothDeviceConnectionFailed") withObject:nil afterDelay:7.0];
|
|
468
|
+
|
|
469
|
+
if (state == RGLBluetoothConnectionStateConnected) {
|
|
470
|
+
savedCallbackForBluetoothResult(@YES);
|
|
471
|
+
savedCallbackForBluetoothResult = nil;
|
|
472
|
+
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:NSSelectorFromString(@"bluetoothDeviceConnectionFailed") object:nil];
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
- (void) bluetoothDeviceConnectionFailed {
|
|
477
|
+
if (savedCallbackForBluetoothResult) {
|
|
478
|
+
savedCallbackForBluetoothResult(@NO);
|
|
479
|
+
savedCallbackForBluetoothResult = nil;
|
|
480
|
+
}
|
|
481
|
+
[bluetooth stopSearchDevices];
|
|
482
|
+
[bluetooth disconnect];
|
|
449
483
|
}
|
|
450
484
|
|
|
451
485
|
- (void) setLocalizationDictionary:(NSDictionary*)dictionary :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
|
|
@@ -476,6 +510,14 @@ NSString* RGLWOnCustomButtonTappedEvent = @"onCustomButtonTappedEvent";
|
|
|
476
510
|
successCallback([RGLWJSONConstructor generateDocReaderVersion:RGLDocReader.shared.version]);
|
|
477
511
|
}
|
|
478
512
|
|
|
513
|
+
- (void) isAuthenticatorRFIDAvailableForUse:(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
|
|
514
|
+
successCallback(RGLDocReader.shared.isAuthenticatorRFIDAvailableForUse ? @YES : @NO);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
- (void) isAuthenticatorAvailableForUse:(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
|
|
518
|
+
successCallback(RGLDocReader.shared.isAuthenticatorAvailableForUse ? @YES : @NO);
|
|
519
|
+
}
|
|
520
|
+
|
|
479
521
|
- (void) getDocReaderDocumentsDatabase:(RGLWCallback)successCallback :(RGLWCallback)errorCallback {
|
|
480
522
|
if(RGLDocReader.shared.version != nil)
|
|
481
523
|
successCallback([RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateDocReaderDocumentsDatabase:RGLDocReader.shared.version.database]]);
|
|
@@ -589,6 +631,11 @@ NSString* RGLWOnCustomButtonTappedEvent = @"onCustomButtonTappedEvent";
|
|
|
589
631
|
}];
|
|
590
632
|
}
|
|
591
633
|
|
|
634
|
+
- (void) endBackendTransaction:(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
|
|
635
|
+
[RGLDocReader.shared endBackendTransaction];
|
|
636
|
+
successCallback(@"");
|
|
637
|
+
}
|
|
638
|
+
|
|
592
639
|
- (void) getTranslation:(NSString*)className :(NSNumber*)value :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
|
|
593
640
|
if([className isEqualToString:@"RFIDErrorCodes"])
|
|
594
641
|
successCallback(RGLRFIDErrorCodesGetStringValue([value intValue]));
|
package/package.json
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regulaforensics/react-native-document-reader-api",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.5.85-rc",
|
|
4
4
|
"description": "React Native module for reading and validation of identification documents (API framework)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
8
|
},
|
|
9
9
|
"keywords": [
|
|
10
|
-
"react-native",
|
|
11
|
-
"documentreader",
|
|
12
|
-
"reader",
|
|
13
|
-
"scanner",
|
|
14
|
-
"regula"
|
|
10
|
+
"react-native", "documentreader", "reader", "scanner", "regula"
|
|
15
11
|
],
|
|
16
12
|
"author": "Regulaforensics",
|
|
17
13
|
"license": "commercial",
|