react-native-scanbot-barcode-scanner-sdk 4.0.0 → 4.0.1-beta.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.
package/android/src/main/java/io/scanbot/barcodesdk/plugin/reactnative/ScanbotBarcodeSdkModule.java
CHANGED
|
@@ -27,6 +27,7 @@ import org.jetbrains.annotations.NotNull;
|
|
|
27
27
|
import java.io.File;
|
|
28
28
|
import java.io.IOException;
|
|
29
29
|
import java.util.ArrayList;
|
|
30
|
+
import java.util.Date;
|
|
30
31
|
import java.util.HashMap;
|
|
31
32
|
import java.util.List;
|
|
32
33
|
import java.util.Map;
|
|
@@ -161,16 +162,18 @@ public class ScanbotBarcodeSdkModule extends ReactContextBaseJavaModule implemen
|
|
|
161
162
|
/** @noinspection unused*/
|
|
162
163
|
@ReactMethod
|
|
163
164
|
public void getLicenseInfo(final Promise promise) {
|
|
164
|
-
if (rejectIfUninitialized(promise)) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
165
|
try {
|
|
168
|
-
WritableMap result = Arguments.createMap();
|
|
169
|
-
ScanbotBarcodeScannerSDK sdk = new ScanbotBarcodeScannerSDK(getReactApplicationContext());
|
|
170
|
-
SdkLicenseInfo licenseInfo = sdk.getLicenseInfo();
|
|
166
|
+
final WritableMap result = Arguments.createMap();
|
|
167
|
+
final ScanbotBarcodeScannerSDK sdk = new ScanbotBarcodeScannerSDK(getReactApplicationContext());
|
|
168
|
+
final SdkLicenseInfo licenseInfo = sdk.getLicenseInfo();
|
|
171
169
|
result.putBoolean("isLicenseValid", licenseInfo.isValid());
|
|
172
170
|
result.putString("licenseStatus", licenseInfo.getStatus().name());
|
|
173
171
|
result.putString("licenseStatusMessage", descriptionFromLicenseStatus(licenseInfo.getStatus()));
|
|
172
|
+
|
|
173
|
+
final Date expirationDate = licenseInfo.getExpirationDate();
|
|
174
|
+
if (expirationDate != null) {
|
|
175
|
+
result.putDouble("licenseExpirationDate", expirationDate.getTime());
|
|
176
|
+
}
|
|
174
177
|
promise.resolve(result);
|
|
175
178
|
} catch (Exception ex) {
|
|
176
179
|
promise.reject(ex);
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InitializationOptions } from "./src/model";
|
|
2
2
|
import { BarcodeScannerConfiguration, BatchBarcodeScannerConfiguration, DetectBarcodesOnImageArguments } from "./src/configuration";
|
|
3
3
|
import { BarcodeDocumentFormat, BarcodeFormat, EngineMode } from "./src/enum";
|
|
4
|
-
import { BarcodeResult, BarcodeScannerResult, BatchBarcodeScannerResult } from "./src/result";
|
|
4
|
+
import { BarcodeResult, BarcodeScannerResult, BatchBarcodeScannerResult, GetLicenseInfoResult } from "./src/result";
|
|
5
5
|
import { ScanbotBarcodeCameraView } from "./src/components/barcode-camera-view/scanbot-barcode-camera-view";
|
|
6
6
|
import { ScanbotBarcodeCameraViewConfiguration} from "./src/components/barcode-camera-view/scanbot-barcode-camera-view-types";
|
|
7
7
|
|
|
@@ -15,13 +15,15 @@ export {
|
|
|
15
15
|
BatchBarcodeScannerResult,
|
|
16
16
|
ScanbotBarcodeCameraView,
|
|
17
17
|
ScanbotBarcodeCameraViewConfiguration,
|
|
18
|
-
EngineMode
|
|
18
|
+
EngineMode,
|
|
19
|
+
GetLicenseInfoResult
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export interface ScanbotBarcodeSdk {
|
|
22
23
|
// SDK Internal
|
|
23
24
|
initializeSdk(options: InitializationOptions): Promise<{ result: string }>;
|
|
24
|
-
getLicenseInfo(): Promise<
|
|
25
|
+
getLicenseInfo(): Promise<GetLicenseInfoResult>;
|
|
26
|
+
|
|
25
27
|
cleanup(): Promise<void>;
|
|
26
28
|
|
|
27
29
|
// RTU-UI Barcode Scanning
|
package/ios/ScanbotBarcodeSdk.m
CHANGED
|
@@ -22,9 +22,13 @@ void runInBackground(void (^function)(void)) {
|
|
|
22
22
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), function);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
@
|
|
25
|
+
@interface ScanbotBarcodeSdk()
|
|
26
|
+
@property(nonatomic, strong) BatchBarcodeScannerPromiseProxy *barcodeBatchProxy;
|
|
27
|
+
@property(nonatomic, strong) BarcodeScannerPromiseProxy *barcodeProxy;
|
|
28
|
+
@property(nonatomic, strong) UIViewController *activeViewController;
|
|
29
|
+
@end
|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
@implementation ScanbotBarcodeSdk
|
|
28
32
|
|
|
29
33
|
RCT_EXPORT_MODULE()
|
|
30
34
|
|
|
@@ -104,15 +108,19 @@ RCT_EXPORT_METHOD(initializeSdk:(NSDictionary *)configuration
|
|
|
104
108
|
RCT_EXPORT_METHOD(getLicenseInfo:(RCTPromiseResolveBlock)resolve
|
|
105
109
|
reject:(RCTPromiseRejectBlock)reject)
|
|
106
110
|
{
|
|
107
|
-
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
resolve(@{
|
|
111
|
+
NSMutableDictionary* result = [[NSMutableDictionary alloc] initWithDictionary:@{
|
|
112
112
|
@"isLicenseValid": @(Scanbot.isLicenseValid),
|
|
113
113
|
@"licenseStatus": [ScanbotBarcodeSdk stringFromLicenseStatus:Scanbot.licenseStatus],
|
|
114
|
-
@"licenseStatusMessage": [ScanbotBarcodeSdk descriptionFromLicenseStatus:Scanbot.licenseStatus]
|
|
115
|
-
}
|
|
114
|
+
@"licenseStatusMessage": [ScanbotBarcodeSdk descriptionFromLicenseStatus:Scanbot.licenseStatus],
|
|
115
|
+
}];
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
NSDate* expirationDate = [Scanbot licenseExpirationDate];
|
|
119
|
+
if (expirationDate) {
|
|
120
|
+
[result setValue:@(expirationDate.timeIntervalSince1970 * 1000) forKey:@"licenseExpirationDate"];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
resolve(result);
|
|
116
124
|
}
|
|
117
125
|
|
|
118
126
|
RCT_EXPORT_METHOD(startBarcodeScanner:(NSDictionary*)configuration
|
|
@@ -166,17 +174,22 @@ RCT_EXPORT_METHOD(startBarcodeScanner:(NSDictionary*)configuration
|
|
|
166
174
|
}
|
|
167
175
|
|
|
168
176
|
bool shouldWaitForGeneratedImage = behaviorConfig.barcodeImageGenerationType != SBSDKBarcodeImageGenerationTypeNone;
|
|
169
|
-
BarcodeScannerPromiseProxy* delegate = [[BarcodeScannerPromiseProxy alloc] initWithResolver: resolve
|
|
170
|
-
shouldIncludeBarcodeImage: shouldWaitForGeneratedImage];
|
|
171
177
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
178
|
+
__weak ScanbotBarcodeSdk *weakSelf = self;
|
|
179
|
+
RCTPromiseResolveBlock proxyResolve = ^(NSDictionary* result){
|
|
180
|
+
weakSelf.activeViewController = nil;
|
|
181
|
+
resolve(result);
|
|
182
|
+
};
|
|
175
183
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
184
|
+
self.barcodeProxy = [[BarcodeScannerPromiseProxy alloc] initWithResolver: proxyResolve
|
|
185
|
+
shouldIncludeBarcodeImage: shouldWaitForGeneratedImage];
|
|
186
|
+
|
|
187
|
+
SBSDKUIBarcodeScannerViewController* viewController = [SBSDKUIBarcodeScannerViewController createNewWithConfiguration:barcodeScannerConfiguration
|
|
188
|
+
andDelegate:self.barcodeProxy];
|
|
189
|
+
|
|
190
|
+
self.activeViewController = viewController;
|
|
191
|
+
|
|
192
|
+
[self presentActiveViewController];
|
|
180
193
|
}
|
|
181
194
|
|
|
182
195
|
RCT_EXPORT_METHOD(startBatchBarcodeScanner:(NSDictionary*)configuration
|
|
@@ -229,18 +242,30 @@ RCT_EXPORT_METHOD(startBatchBarcodeScanner:(NSDictionary*)configuration
|
|
|
229
242
|
batchBarcodeConfig.cameraConfiguration.camera = cameraConfiguration.camera;
|
|
230
243
|
}
|
|
231
244
|
|
|
232
|
-
|
|
233
|
-
|
|
245
|
+
__weak ScanbotBarcodeSdk *weakSelf = self;
|
|
246
|
+
RCTPromiseResolveBlock proxyResolve = ^(NSDictionary* result){
|
|
247
|
+
weakSelf.activeViewController = nil;
|
|
248
|
+
resolve(result);
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
self.barcodeBatchProxy = [[BatchBarcodeScannerPromiseProxy alloc] initWithResolver:proxyResolve];
|
|
252
|
+
|
|
234
253
|
SBSDKUIBarcodesBatchScannerViewController* viewController = [SBSDKUIBarcodesBatchScannerViewController
|
|
235
254
|
createNewWithConfiguration:batchBarcodeConfig
|
|
236
|
-
andDelegate:
|
|
237
|
-
|
|
255
|
+
andDelegate:self.barcodeBatchProxy];
|
|
256
|
+
|
|
257
|
+
self.activeViewController = viewController;
|
|
258
|
+
[self presentActiveViewController];
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
RCT_EXPORT_METHOD(closeBarcodeScanner:(RCTPromiseResolveBlock)resolve
|
|
262
|
+
failure:(RCTPromiseRejectBlock)reject) {
|
|
263
|
+
[self closeActiveViewControllerWithResolveBlock: resolve];
|
|
238
264
|
}
|
|
239
265
|
|
|
240
266
|
RCT_EXPORT_METHOD(closeBatchBarcodeScanner:(RCTPromiseResolveBlock)resolve
|
|
241
267
|
failure:(RCTPromiseRejectBlock)reject) {
|
|
242
|
-
[self
|
|
243
|
-
resolve(nil);
|
|
268
|
+
[self closeActiveViewControllerWithResolveBlock: resolve];
|
|
244
269
|
}
|
|
245
270
|
|
|
246
271
|
RCT_EXPORT_METHOD(detectBarcodesOnImage:(NSDictionary *)configuration
|
|
@@ -314,6 +339,13 @@ RCT_EXPORT_METHOD(cleanup:(RCTPromiseResolveBlock)resolve
|
|
|
314
339
|
});
|
|
315
340
|
}
|
|
316
341
|
|
|
342
|
+
- (void)closeActiveViewControllerWithResolveBlock:(RCTPromiseResolveBlock)resolve {
|
|
343
|
+
[self dismissActiveViewController];
|
|
344
|
+
if (resolve != nil) {
|
|
345
|
+
resolve(nil);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
317
349
|
- (void)reportSuccessWithMessage:(NSString *)message resolve:(RCTPromiseResolveBlock)resolve {
|
|
318
350
|
resolve(@{
|
|
319
351
|
@"status": @"OK",
|
|
@@ -394,55 +426,45 @@ RCT_EXPORT_METHOD(cleanup:(RCTPromiseResolveBlock)resolve
|
|
|
394
426
|
return nil;
|
|
395
427
|
}
|
|
396
428
|
|
|
397
|
-
- (void)
|
|
398
|
-
if (
|
|
429
|
+
- (void)presentActiveViewController {
|
|
430
|
+
if (self.activeViewController == nil) {
|
|
399
431
|
return;
|
|
400
432
|
}
|
|
401
433
|
|
|
402
434
|
UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
|
|
403
|
-
|
|
404
|
-
[rootViewController presentViewController:
|
|
405
|
-
|
|
406
|
-
activeViewController = viewController;
|
|
435
|
+
self.activeViewController.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
436
|
+
[rootViewController presentViewController:self.activeViewController animated:YES completion:nil];
|
|
407
437
|
}
|
|
408
438
|
|
|
409
|
-
- (
|
|
410
|
-
if (
|
|
411
|
-
return
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
if (vcClass && ![activeViewController isKindOfClass:vcClass]) {
|
|
415
|
-
return false;
|
|
439
|
+
- (BOOL)dismissActiveViewController {
|
|
440
|
+
if (self.activeViewController == nil) {
|
|
441
|
+
return NO;
|
|
416
442
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
return true;
|
|
443
|
+
[self.activeViewController dismissViewControllerAnimated:YES completion:nil];
|
|
444
|
+
self.activeViewController = nil;
|
|
445
|
+
return YES;
|
|
422
446
|
}
|
|
423
447
|
|
|
424
448
|
@end
|
|
425
449
|
|
|
426
450
|
/// Barcode Scanner Delegate
|
|
427
|
-
@
|
|
428
|
-
RCTPromiseResolveBlock
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}
|
|
451
|
+
@interface BarcodeScannerPromiseProxy()
|
|
452
|
+
@property(nonatomic, copy) RCTPromiseResolveBlock resolve;
|
|
453
|
+
@property(nonatomic, assign) BOOL shouldIncludeBarcodeImage;
|
|
454
|
+
@property(nonatomic, strong) NSMutableDictionary* resultMessage;
|
|
455
|
+
@end
|
|
433
456
|
|
|
434
|
-
|
|
435
|
-
_resolve = resolve;
|
|
436
|
-
_strongSelf = self;
|
|
437
|
-
_shouldIncludeBarcodeImage = shouldWaitForGeneratedImage;
|
|
438
|
-
_resultMessage = @{@"status": @"OK"}.mutableCopy;
|
|
439
|
-
return [super init];
|
|
440
|
-
}
|
|
457
|
+
@implementation BarcodeScannerPromiseProxy
|
|
441
458
|
|
|
442
|
-
- (
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
459
|
+
- (instancetype)initWithResolver:(nonnull RCTPromiseResolveBlock)resolve
|
|
460
|
+
shouldIncludeBarcodeImage:(bool)shouldWaitForGeneratedImage {
|
|
461
|
+
self = [super init];
|
|
462
|
+
if (self) {
|
|
463
|
+
_resultMessage = @{@"status": @"OK"}.mutableCopy;
|
|
464
|
+
_resolve = resolve;
|
|
465
|
+
_shouldIncludeBarcodeImage = shouldWaitForGeneratedImage;
|
|
466
|
+
}
|
|
467
|
+
return self;
|
|
446
468
|
}
|
|
447
469
|
|
|
448
470
|
- (void)qrBarcodeDetectionViewController:(nonnull SBSDKUIBarcodeScannerViewController *)viewController
|
|
@@ -465,37 +487,37 @@ RCT_EXPORT_METHOD(cleanup:(RCTPromiseResolveBlock)resolve
|
|
|
465
487
|
}
|
|
466
488
|
|
|
467
489
|
[viewController dismissViewControllerAnimated:TRUE completion:nil];
|
|
468
|
-
|
|
490
|
+
self.resolve(self.resultMessage);
|
|
469
491
|
});
|
|
470
492
|
});
|
|
471
493
|
}
|
|
472
494
|
|
|
473
495
|
- (void)qrBarcodeDetectionViewControllerDidCancel:(SBSDKUIBarcodeScannerViewController *)viewController {
|
|
474
|
-
|
|
475
|
-
// release instance
|
|
476
|
-
_strongSelf = nil;
|
|
496
|
+
self.resolve(@{@"status": @"CANCELED"});
|
|
477
497
|
}
|
|
478
498
|
|
|
479
499
|
- (void)qrBarcodeDetectionViewControllerDidTimeout:(SBSDKUIBarcodeScannerViewController *)viewController {
|
|
480
|
-
|
|
500
|
+
self.resolve(@{
|
|
481
501
|
@"status": @"CANCELED",
|
|
482
502
|
@"canceledDueToTimeout": @(true)
|
|
483
503
|
});
|
|
484
|
-
// release instance
|
|
485
|
-
_strongSelf = nil;
|
|
486
504
|
}
|
|
487
505
|
|
|
488
506
|
@end
|
|
489
507
|
|
|
490
508
|
/// Batch Barcode Scanner Delegate
|
|
491
|
-
@
|
|
492
|
-
RCTPromiseResolveBlock
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
509
|
+
@interface BatchBarcodeScannerPromiseProxy()
|
|
510
|
+
@property (nonatomic, copy) RCTPromiseResolveBlock resolve;
|
|
511
|
+
@end
|
|
512
|
+
|
|
513
|
+
@implementation BatchBarcodeScannerPromiseProxy
|
|
514
|
+
|
|
515
|
+
- (instancetype) initWithResolver:(nonnull RCTPromiseResolveBlock)resolve {
|
|
516
|
+
self = [super init];
|
|
517
|
+
if (self) {
|
|
518
|
+
_resolve = resolve;
|
|
519
|
+
}
|
|
520
|
+
return self;
|
|
499
521
|
}
|
|
500
522
|
|
|
501
523
|
- (void)barcodesBatchScannerViewController:(SBSDKUIBarcodesBatchScannerViewController *)
|
|
@@ -507,9 +529,12 @@ RCT_EXPORT_METHOD(cleanup:(RCTPromiseResolveBlock)resolve
|
|
|
507
529
|
@"barcodes": jsonFromMappedBarcodeResults(barcodeResults)
|
|
508
530
|
};
|
|
509
531
|
|
|
510
|
-
|
|
532
|
+
self.resolve(result);
|
|
511
533
|
[viewController dismissViewControllerAnimated:TRUE completion:nil];
|
|
512
|
-
// release instance
|
|
513
|
-
_strongSelf = nil;
|
|
514
534
|
}
|
|
535
|
+
|
|
536
|
+
- (void)barcodesBatchScannerViewControllerDidCancel:(SBSDKUIBarcodesBatchScannerViewController *)viewController {
|
|
537
|
+
self.resolve(@{@"status": @"CANCELED"});
|
|
538
|
+
}
|
|
539
|
+
|
|
515
540
|
@end
|
package/package.json
CHANGED
package/src/enum.ts
CHANGED
|
@@ -6,15 +6,24 @@
|
|
|
6
6
|
|
|
7
7
|
export type Status = "OK" | "CANCELED";
|
|
8
8
|
|
|
9
|
+
/** The SDK license status */
|
|
9
10
|
export type LicenseStatus =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
/** License is valid and accepted. */
|
|
12
|
+
| 'Okay'
|
|
13
|
+
/** No license set yet. The SDK is in trial mode. */
|
|
14
|
+
| 'Trial'
|
|
15
|
+
/** No license set yet. The SDKs trial mode is over. */
|
|
16
|
+
| 'Expired'
|
|
17
|
+
/** No license active. The set license does not cover the current operating system. */
|
|
18
|
+
| 'WrongOS'
|
|
19
|
+
/** No license active. The set license was unreadable or has an invalid format. */
|
|
20
|
+
| 'Corrupted'
|
|
21
|
+
/** No license active. The set licenses does not cover the current apps bundle identifier. */
|
|
22
|
+
| 'AppIDMismatch'
|
|
23
|
+
/** No license set yet. The SDKs trial mode is over. */
|
|
24
|
+
| 'NotSet'
|
|
25
|
+
/** License status is unknown. */
|
|
26
|
+
| 'Unknown';
|
|
18
27
|
|
|
19
28
|
export type CameraImageFormat = "JPG" | "PNG";
|
|
20
29
|
export type DocumentDetectorMode = "EDGE_BASED" | "ML_BASED";
|
package/src/result.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BarcodeFormat, Status } from "./enum";
|
|
1
|
+
import { BarcodeFormat, LicenseStatus, Status } from "./enum";
|
|
2
2
|
|
|
3
3
|
export interface BarcodeResultField {
|
|
4
4
|
/**
|
|
@@ -32,3 +32,14 @@ export type BarcodeScannerResult = BarcodeResult & {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export type BatchBarcodeScannerResult = BarcodeResult;
|
|
35
|
+
|
|
36
|
+
export interface GetLicenseInfoResult {
|
|
37
|
+
/** True if the license is valid, false otherwise */
|
|
38
|
+
isLicenseValid: boolean;
|
|
39
|
+
/** The license status */
|
|
40
|
+
licenseStatus: LicenseStatus;
|
|
41
|
+
/** A short text description of the license status */
|
|
42
|
+
licenseStatusMessage: string;
|
|
43
|
+
/** The license expiration date in milliseconds */
|
|
44
|
+
licenseExpirationDate?: number;
|
|
45
|
+
}
|