react-native-scanbot-barcode-scanner-sdk 4.2.0-beta.1 → 4.2.0-beta.3

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.
@@ -40,13 +40,15 @@ RCT_EXPORT_METHOD(startBarcodeScanner:(NSDictionary*)configuration
40
40
  withResolver:(RCTPromiseResolveBlock)resolve
41
41
  withRejecter:(RCTPromiseRejectBlock)reject) {
42
42
 
43
- UIViewController *presentedViewController = RCTPresentedViewController();
44
-
45
- if (presentedViewController == NULL) {
46
- reject(@"", @"No active view controller", nil);
47
- } else {
48
- [SBBWrapperOperations startBarcodeScannerWithParentViewController:presentedViewController configurationAsDictionary:configuration resultDelegate:[self createResultDelegate:resolve reject:reject]];
49
- }
43
+ runOnMainThread(^{
44
+ UIViewController *presentedViewController = RCTPresentedViewController();
45
+
46
+ if (presentedViewController == NULL) {
47
+ reject(@"", @"No active view controller", nil);
48
+ } else {
49
+ [SBBWrapperOperations startBarcodeScannerWithParentViewController:presentedViewController configurationAsDictionary:configuration resultDelegate:[self createResultDelegate:resolve reject:reject]];
50
+ }
51
+ });
50
52
  }
51
53
 
52
54
  RCT_EXPORT_METHOD(closeBarcodeScanner:
@@ -60,13 +62,15 @@ RCT_EXPORT_METHOD(startBatchBarcodeScanner:(NSDictionary*)configuration
60
62
  withResolver:(RCTPromiseResolveBlock)resolve
61
63
  withRejecter:(RCTPromiseRejectBlock)reject) {
62
64
 
63
- UIViewController *presentedViewController = RCTPresentedViewController();
64
-
65
- if (presentedViewController == NULL) {
66
- reject(@"", @"No active view controller", nil);
67
- } else {
68
- [SBBWrapperOperations startBatchBarcodeScannerWithParentViewController:presentedViewController configurationAsDictionary:configuration resultDelegate:[self createResultDelegate:resolve reject:reject]];
69
- }
65
+ runOnMainThread(^{
66
+ UIViewController *presentedViewController = RCTPresentedViewController();
67
+
68
+ if (presentedViewController == NULL) {
69
+ reject(@"", @"No active view controller", nil);
70
+ } else {
71
+ [SBBWrapperOperations startBatchBarcodeScannerWithParentViewController:presentedViewController configurationAsDictionary:configuration resultDelegate:[self createResultDelegate:resolve reject:reject]];
72
+ }
73
+ });
70
74
  }
71
75
 
72
76
  RCT_EXPORT_METHOD(closeBatchBarcodeScanner:
@@ -96,7 +100,16 @@ RCT_EXPORT_METHOD(extractImagesFromPDF:(NSDictionary *)args
96
100
 
97
101
  + (BOOL)requiresMainQueueSetup
98
102
  {
99
- return NO;
103
+ return NO;
104
+ }
105
+
106
+ void runOnMainThread(void (^block)(void))
107
+ {
108
+ if ([NSThread isMainThread]) {
109
+ block();
110
+ } else {
111
+ dispatch_async(dispatch_get_main_queue(), block);
112
+ }
100
113
  }
101
114
 
102
115
  @end
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-scanbot-barcode-scanner-sdk",
3
3
  "title": "Scanbot Barcode Scanner SDK for React Native",
4
- "version": "4.2.0-beta.1",
4
+ "version": "4.2.0-beta.3",
5
5
  "scanbot": {
6
6
  "iosWrapperVersion": "4.2.2.0-beta.2"
7
7
  },