dynamsoft-capture-vision-react-native 1.0.0 → 1.1.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.
- package/README.md +91 -60
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/dynamsoft/reactlibrary/Constants.java +23 -0
- package/android/src/main/java/com/dynamsoft/reactlibrary/RNDCECameraView.java +5 -26
- package/android/src/main/java/com/dynamsoft/reactlibrary/RNDCECameraViewManager.java +94 -42
- package/android/src/main/java/com/dynamsoft/reactlibrary/RNDynamsoftBarcodeReaderModule.java +32 -3
- package/android/src/main/java/com/dynamsoft/reactlibrary/RNDynamsoftCaptrueVisionPackage.java +13 -2
- package/dynamsoft-capture-vision-react-native.podspec +2 -2
- package/ios/RNDynamsoftCaptureVision/DYSCameraView.h +30 -26
- package/ios/RNDynamsoftCaptureVision/DYSCameraView.m +113 -71
- package/ios/RNDynamsoftCaptureVision/DYSCameraViewManager.h +17 -17
- package/ios/RNDynamsoftCaptureVision/DYSCameraViewManager.m +89 -77
- package/ios/RNDynamsoftCaptureVision/RCTDynamsoftBarcodeReader.h +14 -14
- package/ios/RNDynamsoftCaptureVision/RCTDynamsoftBarcodeReader.m +223 -223
- package/ios/RNDynamsoftCaptureVision/StaticClass.h +26 -26
- package/ios/RNDynamsoftCaptureVision/StaticClass.m +21 -21
- package/js/BarcodeResult.d.ts +25 -0
- package/js/BarcodeResult.js +3 -0
- package/js/BarcodeSettings.d.ts +52 -100
- package/js/BarcodeSettings.js +55 -56
- package/js/BasicStructures.d.ts +20 -0
- package/js/BasicStructures.js +3 -0
- package/js/CameraSettings.d.ts +11 -0
- package/js/CameraSettings.js +9 -0
- package/js/DynamsoftBarcodeReader.d.ts +4 -3
- package/js/DynamsoftBarcodeReader.js +60 -59
- package/js/DynamsoftCameraView.d.ts +31 -7
- package/js/DynamsoftCameraView.js +90 -83
- package/js/index.d.ts +3 -0
- package/js/index.js +23 -3
- package/package.json +8 -1
|
@@ -1,223 +1,223 @@
|
|
|
1
|
-
//
|
|
2
|
-
// RCTDynamsoftBarcodeReader.m
|
|
3
|
-
// RCTDynamsoftBarcodeReader
|
|
4
|
-
//
|
|
5
|
-
// Created by dynamsoft on 2022/3/16.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#import "RCTDynamsoftBarcodeReader.h"
|
|
9
|
-
#import <React/RCTLog.h>
|
|
10
|
-
#import "StaticClass.h"
|
|
11
|
-
|
|
12
|
-
@interface RCTDynamsoftBarcodeReader() <DBRLicenseVerificationListener, DBRTextResultListener>
|
|
13
|
-
|
|
14
|
-
@end
|
|
15
|
-
|
|
16
|
-
@implementation RCTDynamsoftBarcodeReader
|
|
17
|
-
{
|
|
18
|
-
bool hasListeners;
|
|
19
|
-
RCTPromiseResolveBlock licenseResolve;
|
|
20
|
-
RCTPromiseRejectBlock licenseReject;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
- (instancetype)init {
|
|
24
|
-
self = [super init];
|
|
25
|
-
if (self) {
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
return self;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
+ (BOOL)requiresMainQueueSetup{
|
|
32
|
-
return YES;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
- (NSArray<NSString *> *)supportedEvents
|
|
36
|
-
{
|
|
37
|
-
return @[@"resultEvent"];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
-(void)startObserving {
|
|
41
|
-
hasListeners = YES;
|
|
42
|
-
[[StaticClass instance].dbr setDBRTextResultListener:self];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
-(void)stopObserving {
|
|
46
|
-
hasListeners = NO;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
RCT_EXPORT_MODULE(RNDynamsoftBarcodeReader)
|
|
50
|
-
|
|
51
|
-
RCT_EXPORT_METHOD(initLicense:(NSString *)license
|
|
52
|
-
resolver: (RCTPromiseResolveBlock)resolve
|
|
53
|
-
rejecter: (RCTPromiseRejectBlock)reject)
|
|
54
|
-
{
|
|
55
|
-
licenseResolve = resolve;
|
|
56
|
-
licenseReject = reject;
|
|
57
|
-
[DynamsoftBarcodeReader initLicense:license verificationDelegate:self];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
RCT_EXPORT_METHOD(createInstance) {
|
|
61
|
-
[StaticClass instance].dbr = [DynamsoftBarcodeReader new];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getVersion) {
|
|
65
|
-
return [DynamsoftBarcodeReader getVersion];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getInternalVersion) {
|
|
69
|
-
return @"1.0.0";
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
RCT_EXPORT_METHOD(getSettings:(RCTPromiseResolveBlock)resolve
|
|
73
|
-
rejecter: (RCTPromiseRejectBlock)reject)
|
|
74
|
-
{
|
|
75
|
-
NSError *error = [NSError new];
|
|
76
|
-
iPublicRuntimeSettings *settings = [[StaticClass instance].dbr getRuntimeSettings:&error];
|
|
77
|
-
if (error.code != 0) {
|
|
78
|
-
resolve(@(NO));
|
|
79
|
-
}else{
|
|
80
|
-
NSDictionary *barcode = @{
|
|
81
|
-
@"barcodeFormatIds" : [NSNumber numberWithInteger:settings.barcodeFormatIds],
|
|
82
|
-
@"barcodeFormatIds_2" : [NSNumber numberWithInteger:settings.barcodeFormatIds_2],
|
|
83
|
-
@"expectedBarcodeCount" : [NSNumber numberWithInteger:settings.expectedBarcodesCount],
|
|
84
|
-
@"timeout" : [NSNumber numberWithInteger:settings.timeout]
|
|
85
|
-
};
|
|
86
|
-
resolve(barcode);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
RCT_EXPORT_METHOD(resetSettings:(RCTPromiseResolveBlock)resolve
|
|
91
|
-
rejecter: (RCTPromiseRejectBlock)reject)
|
|
92
|
-
{
|
|
93
|
-
NSError *error = [NSError new];
|
|
94
|
-
[[StaticClass instance].dbr resetRuntimeSettings:&error];
|
|
95
|
-
if (error.code != 0) {
|
|
96
|
-
resolve(@(NO));
|
|
97
|
-
}else{
|
|
98
|
-
resolve(@(YES));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
RCT_EXPORT_METHOD(outputSettings:(RCTPromiseResolveBlock)resolve
|
|
103
|
-
rejecter: (RCTPromiseRejectBlock)reject)
|
|
104
|
-
{
|
|
105
|
-
resolve([[StaticClass instance].dbr outputSettingsToString:@"" error:nil]);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
RCT_EXPORT_METHOD(updateSettingsFromString:(NSString *)settings
|
|
109
|
-
resolver: (RCTPromiseResolveBlock)resolve
|
|
110
|
-
rejecter: (RCTPromiseRejectBlock)reject)
|
|
111
|
-
{
|
|
112
|
-
NSError *error = [NSError new];
|
|
113
|
-
[[StaticClass instance].dbr initRuntimeSettingsWithString:settings conflictMode:EnumConflictModeOverwrite error:&error];
|
|
114
|
-
if (error.code != 0) {
|
|
115
|
-
resolve(@(NO));
|
|
116
|
-
}else{
|
|
117
|
-
resolve(@(YES));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
RCT_EXPORT_METHOD(updateSettingsFromDictionary:(NSDictionary *)dic
|
|
122
|
-
resolver: (RCTPromiseResolveBlock)resolve
|
|
123
|
-
rejecter: (RCTPromiseRejectBlock)reject)
|
|
124
|
-
{
|
|
125
|
-
if (dic) {
|
|
126
|
-
NSError *error = [NSError new];
|
|
127
|
-
NSNumber *barcodeFormatIds = [dic valueForKey:@"barcodeFormatIds"];
|
|
128
|
-
NSNumber *barcodeFormatIds_2 = [dic valueForKey:@"barcodeFormatIds_2"];
|
|
129
|
-
NSNumber *expectedBarcodeCount = [dic valueForKey:@"expectedBarcodeCount"];
|
|
130
|
-
NSNumber *timeout = [dic valueForKey:@"timeout"];
|
|
131
|
-
iPublicRuntimeSettings *setting = [[StaticClass instance].dbr getRuntimeSettings:nil];
|
|
132
|
-
setting.barcodeFormatIds = barcodeFormatIds.integerValue;
|
|
133
|
-
setting.barcodeFormatIds_2 = barcodeFormatIds_2.integerValue;
|
|
134
|
-
setting.expectedBarcodesCount = expectedBarcodeCount.integerValue;
|
|
135
|
-
setting.timeout = timeout.integerValue;
|
|
136
|
-
|
|
137
|
-
[[StaticClass instance].dbr updateRuntimeSettings:setting error:&error];
|
|
138
|
-
if (error.code != 0) {
|
|
139
|
-
resolve(@(NO));
|
|
140
|
-
}else{
|
|
141
|
-
resolve(@(YES));
|
|
142
|
-
}
|
|
143
|
-
}else{
|
|
144
|
-
resolve(@(NO));
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
RCT_EXPORT_METHOD(updateSettingsFromNumber:(nonnull NSNumber *)number
|
|
149
|
-
resolver: (RCTPromiseResolveBlock)resolve
|
|
150
|
-
rejecter: (RCTPromiseRejectBlock)reject)
|
|
151
|
-
{
|
|
152
|
-
if (number) {
|
|
153
|
-
if (number.integerValue < 0 || number.integerValue > 6) {
|
|
154
|
-
resolve(@(NO));
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
[[StaticClass instance].dbr updateRuntimeSettings:(EnumPresetTemplate)number.integerValue];
|
|
158
|
-
resolve(@(YES));
|
|
159
|
-
}else{
|
|
160
|
-
resolve(@(NO));
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
RCT_EXPORT_METHOD(startBarcodeScanning) {
|
|
165
|
-
[[StaticClass instance].dbr setCameraEnhancer:[StaticClass instance].dce];
|
|
166
|
-
[[StaticClass instance].dbr startScanning];
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
RCT_EXPORT_METHOD(stopBarcodeScanning) {
|
|
170
|
-
[[StaticClass instance].dbr stopScanning];
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
- (void)DBRLicenseVerificationCallback:(bool)isSuccess error:(NSError * _Nullable)error {
|
|
174
|
-
if(isSuccess){
|
|
175
|
-
licenseResolve(@(YES));
|
|
176
|
-
}else{
|
|
177
|
-
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:error.userInfo options:0 error:nil];
|
|
178
|
-
NSString *msg = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
179
|
-
NSError *err = [NSError errorWithDomain:@"com.dynamsoft.license.error" code:error.code userInfo:nil];
|
|
180
|
-
NSString *code = [NSString stringWithFormat:@"%ld",(long)error.code];
|
|
181
|
-
licenseReject(code, msg, err);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
- (void)textResultCallback:(NSInteger)frameId imageData:(iImageData * _Nonnull)imageData results:(NSArray<iTextResult *> * _Nullable)results {
|
|
186
|
-
if (results.count > 0) {
|
|
187
|
-
NSMutableArray* barcodes = [NSMutableArray array];
|
|
188
|
-
NSString* formatString = @"all";
|
|
189
|
-
for (iTextResult* res in results) {
|
|
190
|
-
if (res.barcodeFormat_2 != EnumBarcodeFormat2NULL) {
|
|
191
|
-
formatString = res.barcodeFormatString_2;
|
|
192
|
-
}else{
|
|
193
|
-
formatString = res.barcodeFormatString;
|
|
194
|
-
}
|
|
195
|
-
NSMutableArray* points = [NSMutableArray array];
|
|
196
|
-
for (int i = 0; i < 4; i++) {
|
|
197
|
-
NSDictionary *point = @{
|
|
198
|
-
@"x": [NSNumber numberWithFloat:[res.localizationResult.resultPoints[i] CGPointValue].x],
|
|
199
|
-
@"y": [NSNumber numberWithFloat:[res.localizationResult.resultPoints[i] CGPointValue].y]
|
|
200
|
-
};
|
|
201
|
-
[points addObject:point];
|
|
202
|
-
}
|
|
203
|
-
NSDictionary *quad = @{
|
|
204
|
-
@"points" : points
|
|
205
|
-
};
|
|
206
|
-
NSDictionary *location = @{
|
|
207
|
-
@"angle" : [NSNumber numberWithInteger:res.localizationResult.angle],
|
|
208
|
-
@"location" : quad
|
|
209
|
-
};
|
|
210
|
-
NSDictionary *barcode = @{
|
|
211
|
-
@"barcodeText" : res.barcodeText,
|
|
212
|
-
@"barcodeFormatString" : formatString,
|
|
213
|
-
@"barcodeLocation" : location
|
|
214
|
-
};
|
|
215
|
-
[barcodes addObject:barcode];
|
|
216
|
-
}
|
|
217
|
-
if (hasListeners) {
|
|
218
|
-
[self sendEventWithName:@"resultEvent" body:[barcodes copy]];
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
@end
|
|
1
|
+
//
|
|
2
|
+
// RCTDynamsoftBarcodeReader.m
|
|
3
|
+
// RCTDynamsoftBarcodeReader
|
|
4
|
+
//
|
|
5
|
+
// Created by dynamsoft on 2022/3/16.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import "RCTDynamsoftBarcodeReader.h"
|
|
9
|
+
#import <React/RCTLog.h>
|
|
10
|
+
#import "StaticClass.h"
|
|
11
|
+
|
|
12
|
+
@interface RCTDynamsoftBarcodeReader() <DBRLicenseVerificationListener, DBRTextResultListener>
|
|
13
|
+
|
|
14
|
+
@end
|
|
15
|
+
|
|
16
|
+
@implementation RCTDynamsoftBarcodeReader
|
|
17
|
+
{
|
|
18
|
+
bool hasListeners;
|
|
19
|
+
RCTPromiseResolveBlock licenseResolve;
|
|
20
|
+
RCTPromiseRejectBlock licenseReject;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
- (instancetype)init {
|
|
24
|
+
self = [super init];
|
|
25
|
+
if (self) {
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
return self;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
+ (BOOL)requiresMainQueueSetup{
|
|
32
|
+
return YES;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
- (NSArray<NSString *> *)supportedEvents
|
|
36
|
+
{
|
|
37
|
+
return @[@"resultEvent"];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
-(void)startObserving {
|
|
41
|
+
hasListeners = YES;
|
|
42
|
+
[[StaticClass instance].dbr setDBRTextResultListener:self];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
-(void)stopObserving {
|
|
46
|
+
hasListeners = NO;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
RCT_EXPORT_MODULE(RNDynamsoftBarcodeReader)
|
|
50
|
+
|
|
51
|
+
RCT_EXPORT_METHOD(initLicense:(NSString *)license
|
|
52
|
+
resolver: (RCTPromiseResolveBlock)resolve
|
|
53
|
+
rejecter: (RCTPromiseRejectBlock)reject)
|
|
54
|
+
{
|
|
55
|
+
licenseResolve = resolve;
|
|
56
|
+
licenseReject = reject;
|
|
57
|
+
[DynamsoftBarcodeReader initLicense:license verificationDelegate:self];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
RCT_EXPORT_METHOD(createInstance) {
|
|
61
|
+
[StaticClass instance].dbr = [DynamsoftBarcodeReader new];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getVersion) {
|
|
65
|
+
return [DynamsoftBarcodeReader getVersion];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getInternalVersion) {
|
|
69
|
+
return @"1.0.0";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
RCT_EXPORT_METHOD(getSettings:(RCTPromiseResolveBlock)resolve
|
|
73
|
+
rejecter: (RCTPromiseRejectBlock)reject)
|
|
74
|
+
{
|
|
75
|
+
NSError *error = [NSError new];
|
|
76
|
+
iPublicRuntimeSettings *settings = [[StaticClass instance].dbr getRuntimeSettings:&error];
|
|
77
|
+
if (error.code != 0) {
|
|
78
|
+
resolve(@(NO));
|
|
79
|
+
}else{
|
|
80
|
+
NSDictionary *barcode = @{
|
|
81
|
+
@"barcodeFormatIds" : [NSNumber numberWithInteger:settings.barcodeFormatIds],
|
|
82
|
+
@"barcodeFormatIds_2" : [NSNumber numberWithInteger:settings.barcodeFormatIds_2],
|
|
83
|
+
@"expectedBarcodeCount" : [NSNumber numberWithInteger:settings.expectedBarcodesCount],
|
|
84
|
+
@"timeout" : [NSNumber numberWithInteger:settings.timeout]
|
|
85
|
+
};
|
|
86
|
+
resolve(barcode);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
RCT_EXPORT_METHOD(resetSettings:(RCTPromiseResolveBlock)resolve
|
|
91
|
+
rejecter: (RCTPromiseRejectBlock)reject)
|
|
92
|
+
{
|
|
93
|
+
NSError *error = [NSError new];
|
|
94
|
+
[[StaticClass instance].dbr resetRuntimeSettings:&error];
|
|
95
|
+
if (error.code != 0) {
|
|
96
|
+
resolve(@(NO));
|
|
97
|
+
}else{
|
|
98
|
+
resolve(@(YES));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
RCT_EXPORT_METHOD(outputSettings:(RCTPromiseResolveBlock)resolve
|
|
103
|
+
rejecter: (RCTPromiseRejectBlock)reject)
|
|
104
|
+
{
|
|
105
|
+
resolve([[StaticClass instance].dbr outputSettingsToString:@"" error:nil]);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
RCT_EXPORT_METHOD(updateSettingsFromString:(NSString *)settings
|
|
109
|
+
resolver: (RCTPromiseResolveBlock)resolve
|
|
110
|
+
rejecter: (RCTPromiseRejectBlock)reject)
|
|
111
|
+
{
|
|
112
|
+
NSError *error = [NSError new];
|
|
113
|
+
[[StaticClass instance].dbr initRuntimeSettingsWithString:settings conflictMode:EnumConflictModeOverwrite error:&error];
|
|
114
|
+
if (error.code != 0) {
|
|
115
|
+
resolve(@(NO));
|
|
116
|
+
}else{
|
|
117
|
+
resolve(@(YES));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
RCT_EXPORT_METHOD(updateSettingsFromDictionary:(NSDictionary *)dic
|
|
122
|
+
resolver: (RCTPromiseResolveBlock)resolve
|
|
123
|
+
rejecter: (RCTPromiseRejectBlock)reject)
|
|
124
|
+
{
|
|
125
|
+
if (dic) {
|
|
126
|
+
NSError *error = [NSError new];
|
|
127
|
+
NSNumber *barcodeFormatIds = [dic valueForKey:@"barcodeFormatIds"];
|
|
128
|
+
NSNumber *barcodeFormatIds_2 = [dic valueForKey:@"barcodeFormatIds_2"];
|
|
129
|
+
NSNumber *expectedBarcodeCount = [dic valueForKey:@"expectedBarcodeCount"];
|
|
130
|
+
NSNumber *timeout = [dic valueForKey:@"timeout"];
|
|
131
|
+
iPublicRuntimeSettings *setting = [[StaticClass instance].dbr getRuntimeSettings:nil];
|
|
132
|
+
setting.barcodeFormatIds = barcodeFormatIds.integerValue;
|
|
133
|
+
setting.barcodeFormatIds_2 = barcodeFormatIds_2.integerValue;
|
|
134
|
+
setting.expectedBarcodesCount = expectedBarcodeCount.integerValue;
|
|
135
|
+
setting.timeout = timeout.integerValue;
|
|
136
|
+
|
|
137
|
+
[[StaticClass instance].dbr updateRuntimeSettings:setting error:&error];
|
|
138
|
+
if (error.code != 0) {
|
|
139
|
+
resolve(@(NO));
|
|
140
|
+
}else{
|
|
141
|
+
resolve(@(YES));
|
|
142
|
+
}
|
|
143
|
+
}else{
|
|
144
|
+
resolve(@(NO));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
RCT_EXPORT_METHOD(updateSettingsFromNumber:(nonnull NSNumber *)number
|
|
149
|
+
resolver: (RCTPromiseResolveBlock)resolve
|
|
150
|
+
rejecter: (RCTPromiseRejectBlock)reject)
|
|
151
|
+
{
|
|
152
|
+
if (number) {
|
|
153
|
+
if (number.integerValue < 0 || number.integerValue > 6) {
|
|
154
|
+
resolve(@(NO));
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
[[StaticClass instance].dbr updateRuntimeSettings:(EnumPresetTemplate)number.integerValue];
|
|
158
|
+
resolve(@(YES));
|
|
159
|
+
}else{
|
|
160
|
+
resolve(@(NO));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
RCT_EXPORT_METHOD(startBarcodeScanning) {
|
|
165
|
+
[[StaticClass instance].dbr setCameraEnhancer:[StaticClass instance].dce];
|
|
166
|
+
[[StaticClass instance].dbr startScanning];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
RCT_EXPORT_METHOD(stopBarcodeScanning) {
|
|
170
|
+
[[StaticClass instance].dbr stopScanning];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
- (void)DBRLicenseVerificationCallback:(bool)isSuccess error:(NSError * _Nullable)error {
|
|
174
|
+
if(isSuccess){
|
|
175
|
+
licenseResolve(@(YES));
|
|
176
|
+
}else{
|
|
177
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:error.userInfo options:0 error:nil];
|
|
178
|
+
NSString *msg = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
179
|
+
NSError *err = [NSError errorWithDomain:@"com.dynamsoft.license.error" code:error.code userInfo:nil];
|
|
180
|
+
NSString *code = [NSString stringWithFormat:@"%ld",(long)error.code];
|
|
181
|
+
licenseReject(code, msg, err);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
- (void)textResultCallback:(NSInteger)frameId imageData:(iImageData * _Nonnull)imageData results:(NSArray<iTextResult *> * _Nullable)results {
|
|
186
|
+
if (results.count > 0) {
|
|
187
|
+
NSMutableArray* barcodes = [NSMutableArray array];
|
|
188
|
+
NSString* formatString = @"all";
|
|
189
|
+
for (iTextResult* res in results) {
|
|
190
|
+
if (res.barcodeFormat_2 != EnumBarcodeFormat2NULL) {
|
|
191
|
+
formatString = res.barcodeFormatString_2;
|
|
192
|
+
}else{
|
|
193
|
+
formatString = res.barcodeFormatString;
|
|
194
|
+
}
|
|
195
|
+
NSMutableArray* points = [NSMutableArray array];
|
|
196
|
+
for (int i = 0; i < 4; i++) {
|
|
197
|
+
NSDictionary *point = @{
|
|
198
|
+
@"x": [NSNumber numberWithFloat:[res.localizationResult.resultPoints[i] CGPointValue].x],
|
|
199
|
+
@"y": [NSNumber numberWithFloat:[res.localizationResult.resultPoints[i] CGPointValue].y]
|
|
200
|
+
};
|
|
201
|
+
[points addObject:point];
|
|
202
|
+
}
|
|
203
|
+
NSDictionary *quad = @{
|
|
204
|
+
@"points" : points
|
|
205
|
+
};
|
|
206
|
+
NSDictionary *location = @{
|
|
207
|
+
@"angle" : [NSNumber numberWithInteger:res.localizationResult.angle],
|
|
208
|
+
@"location" : quad
|
|
209
|
+
};
|
|
210
|
+
NSDictionary *barcode = @{
|
|
211
|
+
@"barcodeText" : res.barcodeText,
|
|
212
|
+
@"barcodeFormatString" : formatString,
|
|
213
|
+
@"barcodeLocation" : location
|
|
214
|
+
};
|
|
215
|
+
[barcodes addObject:barcode];
|
|
216
|
+
}
|
|
217
|
+
if (hasListeners) {
|
|
218
|
+
[self sendEventWithName:@"resultEvent" body:[barcodes copy]];
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
@end
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
//
|
|
2
|
-
// StaticClass.h
|
|
3
|
-
// RCTDynamsoftBarcodeReader
|
|
4
|
-
//
|
|
5
|
-
// Created by dynamsoft on 2022/3/23.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#import <Foundation/Foundation.h>
|
|
9
|
-
#import <DynamsoftBarcodeReader/DynamsoftBarcodeReader.h>
|
|
10
|
-
#import <DynamsoftCameraEnhancer/DynamsoftCameraEnhancerSDK.h>
|
|
11
|
-
|
|
12
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
13
|
-
|
|
14
|
-
@interface StaticClass : NSObject
|
|
15
|
-
|
|
16
|
-
@property (nonatomic, strong) DynamsoftBarcodeReader *dbr;
|
|
17
|
-
|
|
18
|
-
@property (nonatomic, strong) DynamsoftCameraEnhancer *dce;
|
|
19
|
-
|
|
20
|
-
@property (nonatomic, strong) DCECameraView *view;
|
|
21
|
-
|
|
22
|
-
+ (StaticClass *)instance;
|
|
23
|
-
|
|
24
|
-
@end
|
|
25
|
-
|
|
26
|
-
NS_ASSUME_NONNULL_END
|
|
1
|
+
//
|
|
2
|
+
// StaticClass.h
|
|
3
|
+
// RCTDynamsoftBarcodeReader
|
|
4
|
+
//
|
|
5
|
+
// Created by dynamsoft on 2022/3/23.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
#import <DynamsoftBarcodeReader/DynamsoftBarcodeReader.h>
|
|
10
|
+
#import <DynamsoftCameraEnhancer/DynamsoftCameraEnhancerSDK.h>
|
|
11
|
+
|
|
12
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
13
|
+
|
|
14
|
+
@interface StaticClass : NSObject
|
|
15
|
+
|
|
16
|
+
@property (nonatomic, strong) DynamsoftBarcodeReader *dbr;
|
|
17
|
+
|
|
18
|
+
@property (nonatomic, strong) DynamsoftCameraEnhancer *dce;
|
|
19
|
+
|
|
20
|
+
@property (nonatomic, strong) DCECameraView *view;
|
|
21
|
+
|
|
22
|
+
+ (StaticClass *)instance;
|
|
23
|
+
|
|
24
|
+
@end
|
|
25
|
+
|
|
26
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
//
|
|
2
|
-
// StaticClass.m
|
|
3
|
-
// RCTDynamsoftBarcodeReader
|
|
4
|
-
//
|
|
5
|
-
// Created by dynamsoft on 2022/3/23.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#import "StaticClass.h"
|
|
9
|
-
|
|
10
|
-
@implementation StaticClass
|
|
11
|
-
|
|
12
|
-
+ (StaticClass *)instance{
|
|
13
|
-
static StaticClass *instance = nil;
|
|
14
|
-
static dispatch_once_t onceToken;
|
|
15
|
-
dispatch_once(&onceToken, ^{
|
|
16
|
-
instance = [super allocWithZone:NULL];
|
|
17
|
-
});
|
|
18
|
-
return instance;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@end
|
|
1
|
+
//
|
|
2
|
+
// StaticClass.m
|
|
3
|
+
// RCTDynamsoftBarcodeReader
|
|
4
|
+
//
|
|
5
|
+
// Created by dynamsoft on 2022/3/23.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import "StaticClass.h"
|
|
9
|
+
|
|
10
|
+
@implementation StaticClass
|
|
11
|
+
|
|
12
|
+
+ (StaticClass *)instance{
|
|
13
|
+
static StaticClass *instance = nil;
|
|
14
|
+
static dispatch_once_t onceToken;
|
|
15
|
+
dispatch_once(&onceToken, ^{
|
|
16
|
+
instance = [super allocWithZone:NULL];
|
|
17
|
+
});
|
|
18
|
+
return instance;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Quadrilateral } from "./BasicStructures";
|
|
2
|
+
export interface BarcodeResult {
|
|
3
|
+
/**
|
|
4
|
+
* The barcode text.
|
|
5
|
+
*/
|
|
6
|
+
barcodeText: string;
|
|
7
|
+
/**
|
|
8
|
+
* Barcode type in string.
|
|
9
|
+
*/
|
|
10
|
+
barcodeFormatString: string;
|
|
11
|
+
/**
|
|
12
|
+
* The corresponding localization result.
|
|
13
|
+
*/
|
|
14
|
+
barcodeLocation: BarcodeLocationResult;
|
|
15
|
+
}
|
|
16
|
+
export interface BarcodeLocationResult {
|
|
17
|
+
/**
|
|
18
|
+
* The angle of a barcode. Values range from 0 to 360.
|
|
19
|
+
*/
|
|
20
|
+
angle: number;
|
|
21
|
+
/**
|
|
22
|
+
* The quadrilateral
|
|
23
|
+
*/
|
|
24
|
+
quadrilateral: Quadrilateral;
|
|
25
|
+
}
|