anyline-ocr-react-native-module 55.2.1 → 55.6.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/AnylineReact.podspec +1 -1
- package/android/build.gradle +1 -3
- package/android/src/main/AndroidManifest.xml +1 -3
- package/android/src/main/java/com/anyline/reactnative/AnylineSDKPlugin.java +248 -254
- package/index.js +1 -15
- package/ios/AnylineSDKPlugin.h +4 -4
- package/ios/AnylineSDKPlugin.m +278 -211
- package/package.json +1 -1
- package/android/.gradle/7.6/checksums/checksums.lock +0 -0
- package/android/.gradle/7.6/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.6/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.6/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.6/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.6/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/src/main/java/com/anyline/reactnative/FeedbackConfig.java +0 -59
- package/android/src/main/java/com/anyline/reactnative/ImageTextConfig.java +0 -49
- package/android/src/main/java/com/anyline/reactnative/InstructionConfig.java +0 -20
- package/android/src/main/java/com/anyline/reactnative/Offset.java +0 -21
- package/android/src/main/java/com/anyline/reactnative/RotateButtonConfig.java +0 -32
- package/android/src/main/java/com/anyline/reactnative/ScanActivity.java +0 -426
- package/android/src/main/java/com/anyline/reactnative/updateAsset/AnylineUpdateDelegateImpl.java +0 -50
- package/android/src/main/java/com/anyline/reactnative/updateAsset/AssetContextJsonParser.java +0 -28
- package/android/src/main/res/drawable/rotate_screen_background.xml +0 -18
- package/android/src/main/res/drawable/rotate_screen_white.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_flash_auto.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_flash_off.png +0 -0
- package/android/src/main/res/drawable-hdpi/ic_flash_on.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_flash_auto.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_flash_off.png +0 -0
- package/android/src/main/res/drawable-mdpi/ic_flash_on.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_flash_auto.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_flash_off.png +0 -0
- package/android/src/main/res/drawable-xhdpi/ic_flash_on.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_flash_auto.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_flash_off.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/ic_flash_on.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_flash_auto.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_flash_off.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/ic_flash_on.png +0 -0
- package/android/src/main/res/layout/activity_scan.xml +0 -93
- package/ios/ALJsonUIConfiguration.h +0 -54
- package/ios/ALJsonUIConfiguration.m +0 -251
- package/ios/ALPluginHelper.h +0 -48
- package/ios/ALPluginHelper.m +0 -332
- package/ios/ALPluginScanViewController.h +0 -18
- package/ios/ALPluginScanViewController.m +0 -476
- package/ios/ALRoundedView.h +0 -25
- package/ios/ALRoundedView.m +0 -107
package/index.js
CHANGED
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
import {NativeModules} from 'react-native';
|
|
2
2
|
import {version as pluginVersion} from './package.json';
|
|
3
3
|
|
|
4
|
-
const Buffer = require('buffer/').Buffer;
|
|
5
|
-
|
|
6
4
|
const AnylineOCR = NativeModules.AnylineSDKPlugin;
|
|
7
5
|
|
|
8
6
|
export default AnylineOCR;
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
* Decrypts the License and returns the date till it's valid
|
|
12
|
-
*
|
|
13
|
-
* @param License
|
|
14
|
-
*/
|
|
15
|
-
export const getLicenseExpiryDate = (License) => {
|
|
16
|
-
const licenseString = Buffer.from(License, 'base64').toString('ascii');
|
|
17
|
-
const licenseJsonString = licenseString.substr(0, licenseString.lastIndexOf('}')+1);
|
|
18
|
-
const licenseJson = JSON.parse(licenseJsonString);
|
|
19
|
-
return licenseJson.valid;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
AnylineOCR.setPluginVersion(pluginVersion);
|
|
8
|
+
AnylineOCR.setupWrapperSession(pluginVersion);
|
|
23
9
|
|
|
24
10
|
AnylineOCR.getPluginVersion = () => {
|
|
25
11
|
return pluginVersion;
|
package/ios/AnylineSDKPlugin.h
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
#import <Foundation/Foundation.h>
|
|
3
|
-
#import
|
|
3
|
+
#import <Anyline/Anyline.h>
|
|
4
|
+
#import <React/RCTEventEmitter.h>
|
|
5
|
+
#import <React/RCTBridgeModule.h>
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@interface AnylineSDKPlugin : NSObject <RCTBridgeModule>
|
|
7
|
+
@interface AnylineSDKPlugin : RCTEventEmitter <RCTBridgeModule, ALWrapperSessionClientDelegate>
|
|
8
8
|
|
|
9
9
|
@end
|
package/ios/AnylineSDKPlugin.m
CHANGED
|
@@ -1,80 +1,81 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
#import <React/RCTEventEmitter.h>
|
|
3
|
+
#import <React/RCTBridge.h>
|
|
2
4
|
#import "AnylineSDKPlugin.h"
|
|
3
|
-
#import "
|
|
4
|
-
#import "ALPluginScanViewController.h"
|
|
5
|
-
#import "ALPluginHelper.h"
|
|
5
|
+
#import "RCTUtils.h"
|
|
6
6
|
|
|
7
|
-
//
|
|
8
|
-
static
|
|
7
|
+
// Static instance to retain the ALWrapperSessionProvider instance
|
|
8
|
+
static ALWrapperSessionProvider *_wrapperSessionProvider;
|
|
9
9
|
// We're creating a static variable to store the last license used to initialize the SDK
|
|
10
10
|
static NSString *license;
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
static NSString *scanViewConfigPathString;
|
|
13
13
|
|
|
14
14
|
@interface AnylineSDKPlugin()
|
|
15
15
|
|
|
16
16
|
@property (nonatomic, copy) NSString *callbackId;
|
|
17
|
-
@property (nonatomic, assign) BOOL nativeBarcodeScanning;
|
|
18
|
-
@property (nonatomic, strong) NSDictionary *jsonConfigDictionary;
|
|
19
|
-
@property (nonatomic, strong) NSDictionary *ocrConfigDict;
|
|
20
|
-
@property (nonatomic, strong) ALJSONUIConfiguration *jsonUIConf;
|
|
21
|
-
|
|
22
|
-
@property (nonatomic, strong) RCTResponseSenderBlock onResultCallback;
|
|
23
|
-
@property (nonatomic, strong) RCTResponseSenderBlock onErrorCallback;
|
|
24
17
|
|
|
25
18
|
@property (nonatomic, copy) NSString *config;
|
|
26
19
|
|
|
27
20
|
@property (nonatomic, copy) NSString *returnMethod;
|
|
28
21
|
|
|
29
|
-
@property (nonatomic,
|
|
22
|
+
@property (nonatomic, strong) RCTPromiseResolveBlock wrapperSessionSdkInitializationResponsePromiseResolve;
|
|
23
|
+
@property (nonatomic, strong) RCTPromiseRejectBlock wrapperSessionSdkInitializationResponsePromiseReject;
|
|
24
|
+
|
|
25
|
+
@property (nonatomic, strong) RCTPromiseResolveBlock wrapperSessionScanResponsePromiseResolve;
|
|
26
|
+
@property (nonatomic, strong) RCTPromiseRejectBlock wrapperSessionScanResponsePromiseReject;
|
|
27
|
+
|
|
28
|
+
@property (nonatomic, strong) RCTResponseSenderBlock scanResponseResultCallback;
|
|
29
|
+
@property (nonatomic, strong) RCTResponseSenderBlock scanResponseErrorCallback;
|
|
30
|
+
|
|
31
|
+
@property (nonatomic, strong) RCTPromiseResolveBlock wrapperSessionExportCachedEventsPromiseResolve;
|
|
32
|
+
@property (nonatomic, strong) RCTPromiseRejectBlock wrapperSessionExportCachedEventsPromiseReject;
|
|
33
|
+
|
|
34
|
+
@property (nonatomic, strong) RCTResponseSenderBlock reportCorrectedResultResponseCallback;
|
|
35
|
+
@property (nonatomic, strong) RCTResponseSenderBlock reportCorrectedResultErrorCallback;
|
|
30
36
|
|
|
31
37
|
@end
|
|
32
38
|
|
|
33
39
|
|
|
34
40
|
@implementation AnylineSDKPlugin {
|
|
35
|
-
|
|
36
|
-
RCTPromiseRejectBlock _rejectBlock;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
+ (BOOL)isInitializedWithLicenseKey:(NSString *)requestedLicense {
|
|
40
|
-
return (license && [AnylineSDK isInitialized] && [license isEqualToString:requestedLicense]);
|
|
41
|
+
NSMutableArray<NSString *> *supportedRTCEventsArray;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
- (instancetype)init {
|
|
44
|
-
self = [super
|
|
45
|
+
self = [super initWithDisabledObservation];
|
|
45
46
|
if (self) {
|
|
46
|
-
if (!
|
|
47
|
-
// Initialize the
|
|
48
|
-
|
|
47
|
+
if (!_wrapperSessionProvider) {
|
|
48
|
+
// Initialize the wrapperSessionProvider static variable
|
|
49
|
+
_wrapperSessionProvider = [[ALWrapperSessionProvider alloc] init];
|
|
49
50
|
}
|
|
51
|
+
supportedRTCEventsArray = [NSMutableArray array];
|
|
50
52
|
}
|
|
51
53
|
return self;
|
|
52
54
|
}
|
|
53
55
|
|
|
56
|
+
+ (BOOL)isInitializedWithLicenseKey:(NSString *)requestedLicense {
|
|
57
|
+
ALWrapperSessionSDKInitializationResponse *currentSdkInitializationResponse = [ALWrapperSessionProvider getCurrentSdkInitializationResponse];
|
|
58
|
+
return (license
|
|
59
|
+
&& currentSdkInitializationResponse.initialized != 0
|
|
60
|
+
&& [license isEqualToString:requestedLicense]);
|
|
61
|
+
}
|
|
62
|
+
|
|
54
63
|
RCT_EXPORT_MODULE();
|
|
64
|
+
|
|
55
65
|
- (UIView *)view {
|
|
56
66
|
return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
|
|
57
67
|
}
|
|
58
68
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
self.onResultCallback = onResult;
|
|
62
|
-
self.onErrorCallback = onError;
|
|
63
|
-
self.returnMethod = @"callback";
|
|
64
|
-
self.config = config;
|
|
65
|
-
[self initView:scanMode initializationParamsStr:nil];
|
|
69
|
+
RCT_EXPORT_METHOD(getSDKVersion:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
70
|
+
resolve(AnylineSDK.versionNumber);
|
|
66
71
|
}
|
|
67
72
|
|
|
68
|
-
RCT_EXPORT_METHOD(
|
|
69
|
-
[self
|
|
73
|
+
RCT_EXPORT_METHOD(setupWrapperSession:(NSString *)pluginVersion) {
|
|
74
|
+
[self setupWrapperSessionWithPluginVersion:pluginVersion];
|
|
70
75
|
}
|
|
71
76
|
|
|
72
|
-
RCT_EXPORT_METHOD(
|
|
73
|
-
|
|
74
|
-
self.onErrorCallback = onError;
|
|
75
|
-
self.returnMethod = @"callback";
|
|
76
|
-
self.config = config;
|
|
77
|
-
[self initView:scanMode initializationParamsStr:initializationParametersStr];
|
|
77
|
+
RCT_EXPORT_METHOD(setViewConfigsPath:(NSString *)path) {
|
|
78
|
+
scanViewConfigPathString = path;
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
RCT_EXPORT_METHOD(setupAnylineSDK:(NSString *)licenseKey
|
|
@@ -88,226 +89,201 @@ RCT_EXPORT_METHOD(setupAnylineSDKWithCacheConfig:(NSString *)licenseKey
|
|
|
88
89
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
89
90
|
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
self.wrapperSessionSdkInitializationResponsePromiseResolve = resolve;
|
|
93
|
+
self.wrapperSessionSdkInitializationResponsePromiseReject = reject;
|
|
93
94
|
self.returnMethod = @"promise";
|
|
94
95
|
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
[self initSdkWithLicenseKey:licenseKey sdkAssetsFolder:nil enableOfflineCache:enableOfflineCache];
|
|
97
|
+
}
|
|
97
98
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
RCT_EXPORT_METHOD(isInitialized:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
100
|
+
ALWrapperSessionSDKInitializationResponse *currentSdkInitializationResponse = [ALWrapperSessionProvider getCurrentSdkInitializationResponse];
|
|
101
|
+
BOOL isInitialized = (currentSdkInitializationResponse.initialized != 0);
|
|
102
|
+
resolve(@(isInitialized));
|
|
103
|
+
}
|
|
102
104
|
|
|
103
|
-
|
|
105
|
+
RCT_EXPORT_METHOD(licenseKeyExpiryDate:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
106
|
+
ALWrapperSessionSDKInitializationResponse *currentSdkInitializationResponse = [ALWrapperSessionProvider getCurrentSdkInitializationResponse];
|
|
107
|
+
if (currentSdkInitializationResponse.initialized != 0) {
|
|
108
|
+
ALWrapperSessionSDKInitializationResponseInitialized *sdkInitializationResponseInitialized = currentSdkInitializationResponse.succeedInfo;
|
|
109
|
+
if (sdkInitializationResponseInitialized) {
|
|
110
|
+
resolve(sdkInitializationResponseInitialized.expiryDate);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// not `reject`, as this will require the method to be used in a try-catch
|
|
115
|
+
resolve(nil);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
104
118
|
|
|
105
|
-
|
|
119
|
+
// Deprecated
|
|
120
|
+
RCT_EXPORT_METHOD(setupScanViewWithConfigJson:(NSString *)config scanMode:(NSString *)scanMode onResultCallback:(RCTResponseSenderBlock)onResult onErrorCallback:(RCTResponseSenderBlock)onError) {
|
|
121
|
+
[self setupWithInitializationParameters:nil config:config scanMode:scanMode onResultCallback:onResult onErrorCallback:onError];
|
|
122
|
+
}
|
|
106
123
|
|
|
107
|
-
|
|
108
|
-
|
|
124
|
+
RCT_EXPORT_METHOD(setup:(NSString *)config scanMode:(NSString *)scanMode onResultCallback:(RCTResponseSenderBlock)onResult onErrorCallback:(RCTResponseSenderBlock)onError) {
|
|
125
|
+
[self setupWithInitializationParameters:nil config:config scanMode:scanMode onResultCallback:onResult onErrorCallback:onError];
|
|
126
|
+
}
|
|
109
127
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
128
|
+
RCT_EXPORT_METHOD(setupWithInitializationParameters:(NSString * _Nullable)initializationParametersStr config:(NSString *)config scanMode:(NSString *)scanMode onResultCallback:(RCTResponseSenderBlock)onResult onErrorCallback:(RCTResponseSenderBlock)onError) {
|
|
129
|
+
self.scanResponseResultCallback = onResult;
|
|
130
|
+
self.scanResponseErrorCallback = onError;
|
|
131
|
+
self.returnMethod = @"callback";
|
|
116
132
|
|
|
117
|
-
|
|
118
|
-
|
|
133
|
+
[self requestScanStartWithScanViewConfigContent:config
|
|
134
|
+
scanViewInitializationParametersString:initializationParametersStr
|
|
135
|
+
scanViewConfigPath:scanViewConfigPathString
|
|
136
|
+
scanCallbackConfigString:nil];
|
|
119
137
|
}
|
|
120
138
|
|
|
121
139
|
RCT_EXPORT_METHOD(setupPromise:(NSString *)config scanMode:(NSString *)scanMode resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
122
140
|
[self setupPromiseWithInitializationParameters:nil config:config scanMode:scanMode resolver:resolve rejecter:reject];
|
|
123
141
|
}
|
|
124
142
|
|
|
125
|
-
RCT_EXPORT_METHOD(setupPromiseWithInitializationParameters:(NSString * _Nullable)initializationParametersStr
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
self
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
143
|
+
RCT_EXPORT_METHOD(setupPromiseWithInitializationParameters:(NSString * _Nullable)initializationParametersStr
|
|
144
|
+
config:(NSString *)configStr
|
|
145
|
+
scanMode:(NSString *)scanMode
|
|
146
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
147
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
148
|
+
[self setupPromiseWithInitializationParametersAndScanCallbackConfig:initializationParametersStr
|
|
149
|
+
config:configStr
|
|
150
|
+
scanMode:scanMode
|
|
151
|
+
scanCallbackConfigString:nil
|
|
152
|
+
resolver:resolve
|
|
153
|
+
rejecter:reject];
|
|
136
154
|
}
|
|
137
155
|
|
|
138
|
-
RCT_EXPORT_METHOD(
|
|
139
|
-
|
|
156
|
+
RCT_EXPORT_METHOD(setupPromiseWithScanCallbackConfig:(NSString *)configStr
|
|
157
|
+
scanMode:(NSString *)scanMode
|
|
158
|
+
scanCallbackConfigString:(NSString *)scanCallbackConfigString
|
|
159
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
160
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
161
|
+
[self setupPromiseWithInitializationParametersAndScanCallbackConfig:nil
|
|
162
|
+
config:configStr
|
|
163
|
+
scanMode:scanMode
|
|
164
|
+
scanCallbackConfigString:scanCallbackConfigString
|
|
165
|
+
resolver:resolve
|
|
166
|
+
rejecter:reject];
|
|
140
167
|
}
|
|
141
168
|
|
|
142
|
-
RCT_EXPORT_METHOD(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
169
|
+
RCT_EXPORT_METHOD(setupPromiseWithInitializationParametersAndScanCallbackConfig:(NSString * _Nullable)initializationParametersStr
|
|
170
|
+
config:(NSString *)configStr
|
|
171
|
+
scanMode:(NSString *)scanMode
|
|
172
|
+
scanCallbackConfigString:(NSString * _Nullable)scanCallbackConfigString
|
|
173
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
174
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
175
|
+
self.wrapperSessionScanResponsePromiseResolve = resolve;
|
|
176
|
+
self.wrapperSessionScanResponsePromiseReject = reject;
|
|
177
|
+
self.returnMethod = @"promise";
|
|
178
|
+
[self requestScanStartWithScanViewConfigContent:configStr
|
|
179
|
+
scanViewInitializationParametersString:initializationParametersStr
|
|
180
|
+
scanViewConfigPath:scanViewConfigPathString
|
|
181
|
+
scanCallbackConfigString:scanCallbackConfigString];
|
|
150
182
|
}
|
|
151
183
|
|
|
152
|
-
RCT_EXPORT_METHOD(
|
|
153
|
-
|
|
154
|
-
resolve(@(isInitialized));
|
|
184
|
+
RCT_EXPORT_METHOD(tryStopScan:(NSString * _Nullable)scanStopRequestParams) {
|
|
185
|
+
[ALWrapperSessionProvider requestScanStopWithScanStopRequestParamsString:scanStopRequestParams];
|
|
155
186
|
}
|
|
156
187
|
|
|
157
188
|
RCT_EXPORT_METHOD(reportCorrectedResult:(NSString *)blobKey
|
|
158
189
|
correctedResult:(NSString *)correctedResult
|
|
159
190
|
onResultCallback:(RCTResponseSenderBlock)onResult
|
|
160
191
|
onErrorCallback:(RCTResponseSenderBlock)onError) {
|
|
192
|
+
self.reportCorrectedResultResponseCallback = onResult;
|
|
193
|
+
self.reportCorrectedResultErrorCallback = onError;
|
|
161
194
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
NSString *response = [ALScanResult reportCorrectedResultFromBlobKey:blobKey
|
|
165
|
-
correctedResult:correctedResult
|
|
166
|
-
apiKey:nil // apiKey should be nil
|
|
167
|
-
error:&error];
|
|
168
|
-
if (response) {
|
|
169
|
-
NSError *jsonError = nil;
|
|
170
|
-
NSData *jsonData = [response dataUsingEncoding:NSUTF8StringEncoding];
|
|
171
|
-
NSDictionary *correctedResultJson = [NSJSONSerialization JSONObjectWithData:jsonData
|
|
172
|
-
options:0
|
|
173
|
-
error:&jsonError];
|
|
174
|
-
if (jsonError) {
|
|
175
|
-
onError(@[jsonError.localizedDescription]);
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
NSNumber *correctedResultCode = [correctedResultJson objectForKey:@"code"];
|
|
180
|
-
NSString *correctedResultMessage = [correctedResultJson objectForKey:@"message"];
|
|
181
|
-
|
|
182
|
-
if ([correctedResultCode intValue] == 200) {
|
|
183
|
-
NSString *correctedResultInternalMessage = @"";
|
|
184
|
-
if (correctedResultMessage) {
|
|
185
|
-
NSError *messageJsonError = nil;
|
|
186
|
-
NSData *messageJsonData = [correctedResultMessage dataUsingEncoding:NSUTF8StringEncoding];
|
|
187
|
-
NSDictionary *messageJson = [NSJSONSerialization JSONObjectWithData:messageJsonData
|
|
188
|
-
options:0
|
|
189
|
-
error:&messageJsonError];
|
|
190
|
-
if (!messageJsonError) {
|
|
191
|
-
correctedResultInternalMessage = [messageJson objectForKey:@"message"];
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
onResult(@[correctedResultInternalMessage]);
|
|
195
|
-
} else {
|
|
196
|
-
onError(@[correctedResultMessage]);
|
|
197
|
-
}
|
|
198
|
-
} else {
|
|
199
|
-
onError(@[error.localizedDescription]);
|
|
200
|
-
}
|
|
195
|
+
[self requestUCRReportWithBlobKey:blobKey correctedResult:correctedResult];
|
|
201
196
|
}
|
|
202
197
|
|
|
203
198
|
|
|
204
199
|
RCT_EXPORT_METHOD(exportCachedEvents:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
self
|
|
200
|
+
self.wrapperSessionExportCachedEventsPromiseResolve = resolve;
|
|
201
|
+
self.wrapperSessionExportCachedEventsPromiseReject = reject;
|
|
202
|
+
[self exportCachedEvents];
|
|
203
|
+
}
|
|
208
204
|
|
|
209
|
-
NSError *error;
|
|
210
|
-
NSString *exportPath = [AnylineSDK exportCachedEvents:&error];
|
|
211
205
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
[self returnError:[NSError errorWithDomain:@"ALReactDomain" code:100 userInfo:@{NSLocalizedDescriptionKey: errorString}]];
|
|
215
|
-
} else {
|
|
216
|
-
[self returnSuccess:exportPath];
|
|
217
|
-
}
|
|
206
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
207
|
+
return supportedRTCEventsArray;
|
|
218
208
|
}
|
|
219
209
|
|
|
210
|
+
- (void)sendEvent:(NSString *)eventName
|
|
211
|
+
params:(id _Nullable) params {
|
|
220
212
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
if (!data) {
|
|
224
|
-
[NSException raise:@"Config could not be loaded from disk" format:@"Config could not be loaded from disk"];
|
|
213
|
+
if (![supportedRTCEventsArray containsObject:eventName]) {
|
|
214
|
+
[supportedRTCEventsArray addObject:eventName];
|
|
225
215
|
}
|
|
226
216
|
|
|
227
|
-
|
|
228
|
-
|
|
217
|
+
[self sendEventWithName:eventName body:params];
|
|
218
|
+
}
|
|
229
219
|
|
|
230
|
-
|
|
231
|
-
|
|
220
|
+
-(NSString *)bundleRootPath {
|
|
221
|
+
NSString *rootPath = [[NSBundle mainBundle] bundlePath];
|
|
222
|
+
return rootPath;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
-(NSString *)bundlePathFromScanViewConfigPath:(NSString * _Nullable)scanViewConfigPath {
|
|
226
|
+
//get root folder (ends with ...Runner.app)
|
|
227
|
+
NSString *absoluteScanViewConfigPath = [self bundleRootPath];
|
|
228
|
+
|
|
229
|
+
if (scanViewConfigPath) {
|
|
230
|
+
//append scanViewConfigPath
|
|
231
|
+
absoluteScanViewConfigPath = [absoluteScanViewConfigPath stringByAppendingPathComponent:scanViewConfigPath];
|
|
232
232
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
BOOL nativeBarcodeScanning = [[optionsDictionary objectForKey:@"nativeBarcodeEnabled"] boolValue];
|
|
237
|
-
self.nativeBarcodeScanning = nativeBarcodeScanning ? nativeBarcodeScanning : NO;
|
|
238
|
-
|
|
239
|
-
self.jsonUIConf = [[ALJSONUIConfiguration alloc] initWithDictionary:optionsDictionary];
|
|
240
|
-
self.ocrConfigDict = [dictionary objectForKey:@"ocr"];
|
|
241
|
-
|
|
242
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
243
|
-
[[UIApplication sharedApplication] keyWindow].rootViewController.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
244
|
-
|
|
245
|
-
if ([[scanMode uppercaseString] isEqualToString:[@"scan" uppercaseString]]) {
|
|
246
|
-
ALPluginScanViewController *pluginScanViewController =
|
|
247
|
-
[[ALPluginScanViewController alloc] initWithLicensekey:license
|
|
248
|
-
configuration:dictionary
|
|
249
|
-
uiConfiguration:self.jsonUIConf
|
|
250
|
-
initializationParamsStr:initializationParamsStr
|
|
251
|
-
finished:^(NSDictionary * _Nullable callbackObj, NSError * _Nullable error) {
|
|
252
|
-
[self returnCallback:callbackObj andError:error];
|
|
253
|
-
}];
|
|
254
|
-
|
|
255
|
-
if (pluginScanViewController != nil){
|
|
256
|
-
[pluginScanViewController setModalPresentationStyle: UIModalPresentationFullScreen];
|
|
257
|
-
[[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:pluginScanViewController animated:YES completion:nil];
|
|
258
|
-
}
|
|
259
|
-
} else {
|
|
260
|
-
ALPluginScanViewController *pluginScanViewController =
|
|
261
|
-
[[ALPluginScanViewController alloc] initWithLicensekey:license
|
|
262
|
-
configuration:dictionary
|
|
263
|
-
uiConfiguration:self.jsonUIConf
|
|
264
|
-
initializationParamsStr:initializationParamsStr
|
|
265
|
-
finished:^(NSDictionary * _Nullable callbackObj, NSError * _Nullable error) {
|
|
266
|
-
[self returnCallback:callbackObj andError:error];
|
|
267
|
-
}];
|
|
268
|
-
|
|
269
|
-
if (pluginScanViewController != nil){
|
|
270
|
-
[pluginScanViewController setModalPresentationStyle: UIModalPresentationFullScreen];
|
|
271
|
-
[[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:pluginScanViewController animated:YES completion:nil];
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
});
|
|
233
|
+
return absoluteScanViewConfigPath;
|
|
234
|
+
}
|
|
275
235
|
|
|
236
|
+
- (void)setupWrapperSessionWithPluginVersion:(NSString *)pluginVersion {
|
|
237
|
+
// Setup wrapper session with this view controller as delegate
|
|
238
|
+
ALWrapperConfig *wrapperConfig = [ALWrapperConfig reactNative:pluginVersion];
|
|
239
|
+
[ALWrapperSessionProvider setupWrapperSessionWithWrapperInfo:wrapperConfig
|
|
240
|
+
wrapperSessionClient:self];
|
|
276
241
|
}
|
|
277
242
|
|
|
278
|
-
|
|
243
|
+
- (void)initSdkWithLicenseKey:(NSString *)sdkLicenseKey
|
|
244
|
+
sdkAssetsFolder: (NSString *)sdkAssetsFolder
|
|
245
|
+
enableOfflineCache: (BOOL)enableOfflineCache {
|
|
246
|
+
NSDictionary *wrapperSessionSdkInitializationRequestJson = [ALLegacyPluginHelper
|
|
247
|
+
sdkInitializationRequestJsonWithLicenseKey:sdkLicenseKey
|
|
248
|
+
enableOfflineCache:enableOfflineCache
|
|
249
|
+
assetPathPrefix:sdkAssetsFolder];
|
|
279
250
|
|
|
280
|
-
|
|
281
|
-
|
|
251
|
+
[ALWrapperSessionProvider
|
|
252
|
+
requestSdkInitializationWithInitializationRequestParamsString:[wrapperSessionSdkInitializationRequestJson asJSONString]];
|
|
253
|
+
}
|
|
282
254
|
|
|
255
|
+
- (void)requestScanStartWithScanViewConfigContent:(NSString *)scanViewConfigContent
|
|
256
|
+
scanViewInitializationParametersString:(NSString * _Nullable)scanViewInitializationParametersString
|
|
257
|
+
scanViewConfigPath:(NSString * _Nullable)scanViewConfigPath
|
|
258
|
+
scanCallbackConfigString:(NSString * _Nullable)scanCallbackConfigString {
|
|
283
259
|
NSError *error;
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
260
|
+
BOOL shouldReturnImages = true;
|
|
261
|
+
|
|
262
|
+
ALWrapperSessionScanStartRequest *wrapperSessionScanStartRequest = [ALLegacyPluginHelper
|
|
263
|
+
scanStartRequestWithScanViewConfigContentString:scanViewConfigContent
|
|
264
|
+
scanViewInitializationParametersString:scanViewInitializationParametersString
|
|
265
|
+
scanViewConfigPath:[self bundlePathFromScanViewConfigPath:scanViewConfigPath]
|
|
266
|
+
scanResultCallbackConfigString:scanCallbackConfigString
|
|
267
|
+
shouldReturnImages:shouldReturnImages
|
|
268
|
+
error:&error];
|
|
269
|
+
if (error) {
|
|
270
|
+
[self returnError:error];
|
|
290
271
|
} else {
|
|
291
|
-
|
|
272
|
+
NSDictionary *wrapperSessionScanStartRequestDict = [wrapperSessionScanStartRequest toJSONDictionary];
|
|
273
|
+
[ALWrapperSessionProvider requestScanStartWithScanStartRequestParamsString:[wrapperSessionScanStartRequestDict asJSONString]];
|
|
292
274
|
}
|
|
293
|
-
[self returnSuccess:resultJson];
|
|
294
275
|
}
|
|
295
276
|
|
|
296
|
-
- (void)
|
|
297
|
-
|
|
298
|
-
}
|
|
277
|
+
- (void)requestUCRReportWithBlobKey:(NSString *)blobKey
|
|
278
|
+
correctedResult:(NSString *)correctedResult {
|
|
299
279
|
|
|
300
|
-
|
|
301
|
-
|
|
280
|
+
ALWrapperSessionUCRReportRequest *wrapperSessionSdkInitializationRequest = [ALLegacyPluginHelper ucrReportRequestWithBlobKey:blobKey
|
|
281
|
+
correctedResult:correctedResult];
|
|
282
|
+
[ALWrapperSessionProvider requestUCRReport:wrapperSessionSdkInitializationRequest];
|
|
302
283
|
}
|
|
303
284
|
|
|
304
|
-
-
|
|
305
|
-
|
|
306
|
-
NSArray *possibleScanModes = @[@"DOCUMENT", @"MRZ", @"BARCODE", @"LICENSE_PLATE", @"LICENSE_PLATE_US", @"ANYLINE_OCR", @"TIRE", @"ANALOG_METER", @"DIGITAL_METER", @"AUTO_ANALOG_DIGITAL_METER",
|
|
307
|
-
@"DIAL_METER", @"SERIAL_NUMBER", @"HEAT_METER_4", @"HEAT_METER_5", @"HEAT_METER_6", @"DOT_MATRIX_METER"];
|
|
308
|
-
|
|
309
|
-
return [possibleScanModes containsObject: [scanMode uppercaseString]];
|
|
310
|
-
|
|
285
|
+
-(void)exportCachedEvents {
|
|
286
|
+
[ALWrapperSessionProvider requestExportCachedEvents];
|
|
311
287
|
}
|
|
312
288
|
|
|
313
289
|
- (void)returnCallback:(id _Nullable)callbackObj andError:(NSError * _Nullable)error {
|
|
@@ -329,17 +305,108 @@ RCT_EXPORT_METHOD(exportCachedEvents:(RCTPromiseResolveBlock)resolve rejecter:(R
|
|
|
329
305
|
|
|
330
306
|
- (void)returnSuccess:(NSString *)result {
|
|
331
307
|
if ([self.returnMethod isEqualToString:@"callback"]) {
|
|
332
|
-
self.
|
|
308
|
+
self.scanResponseResultCallback(@[result]);
|
|
333
309
|
} else if ([self.returnMethod isEqualToString:@"promise"]) {
|
|
334
|
-
|
|
310
|
+
if (self.wrapperSessionScanResponsePromiseResolve) {
|
|
311
|
+
self.wrapperSessionScanResponsePromiseResolve(result);
|
|
312
|
+
}
|
|
313
|
+
self.wrapperSessionScanResponsePromiseResolve = nil;
|
|
335
314
|
}
|
|
336
315
|
}
|
|
337
316
|
|
|
338
317
|
- (void)returnError:(NSError *)error {
|
|
339
318
|
if ([self.returnMethod isEqualToString:@"callback"]) {
|
|
340
|
-
self.
|
|
319
|
+
self.scanResponseErrorCallback(@[error]);
|
|
341
320
|
} else if ([self.returnMethod isEqualToString:@"promise"]) {
|
|
342
|
-
|
|
321
|
+
if (self.wrapperSessionScanResponsePromiseReject) {
|
|
322
|
+
self.wrapperSessionScanResponsePromiseReject(@"ANYLINE_ERROR", error.localizedDescription, error);
|
|
323
|
+
}
|
|
324
|
+
self.wrapperSessionScanResponsePromiseReject = nil;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
#pragma mark - ALWrapperSessionClientDelegate
|
|
329
|
+
|
|
330
|
+
- (nullable UIViewController *)getTopViewController {
|
|
331
|
+
UIViewController *topViewController = RCTPresentedViewController();
|
|
332
|
+
if (!topViewController) {
|
|
333
|
+
topViewController = [[UIApplication sharedApplication] keyWindow].rootViewController;
|
|
334
|
+
return topViewController;
|
|
335
|
+
}
|
|
336
|
+
return nil;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
- (void)onSdkInitializationResponse:(nonnull ALWrapperSessionSDKInitializationResponse *)initializationResponse {
|
|
340
|
+
if (initializationResponse.initialized) {
|
|
341
|
+
self.wrapperSessionSdkInitializationResponsePromiseResolve(@"success");
|
|
342
|
+
} else {
|
|
343
|
+
self.wrapperSessionSdkInitializationResponsePromiseReject(@"ANYLINE_ERROR", [[initializationResponse toJSONDictionary] asJSONString], nil);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
- (void)onScanResults:(nonnull ALWrapperSessionScanResultsResponse *)scanResultsResponse {
|
|
348
|
+
ALWrapperSessionScanResultConfig *scanResultConfig = scanResultsResponse.scanResultConfig;
|
|
349
|
+
NSArray<ALExportedScanResult *> *exportedScanResultsArray = (NSArray<ALExportedScanResult *> *) scanResultsResponse.exportedScanResults;
|
|
350
|
+
ALWrapperSessionScanResultExtraInfo *scanResultExtraInfo = scanResultsResponse.scanResultExtraInfo;
|
|
351
|
+
|
|
352
|
+
NSError *error;
|
|
353
|
+
NSString *resultsWithImagePathString = [ALLegacyPluginHelper scanResultsWithImagePathFromExportedScanResults:exportedScanResultsArray
|
|
354
|
+
viewPluginType:scanResultExtraInfo.viewPluginType
|
|
355
|
+
error:&error];
|
|
356
|
+
|
|
357
|
+
if (scanResultConfig.callbackConfig && scanResultConfig.callbackConfig.onResultEventName) {
|
|
358
|
+
[self sendEvent:scanResultConfig.callbackConfig.onResultEventName params:resultsWithImagePathString];
|
|
359
|
+
} else {
|
|
360
|
+
[self returnSuccess:resultsWithImagePathString];
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
- (void)onScanResponse:(nonnull ALWrapperSessionScanResponse *)scanResponse {
|
|
365
|
+
if (scanResponse.status == ALWrapperSessionScanResponseStatus.scanSucceeded) {
|
|
366
|
+
ALWrapperSessionScanResultConfig *scanResultConfig = scanResponse.scanResultConfig;
|
|
367
|
+
if (scanResultConfig.callbackConfig && scanResultConfig.callbackConfig.onResultEventName) {
|
|
368
|
+
[self returnSuccess:@""];
|
|
369
|
+
}
|
|
370
|
+
} else if (scanResponse.status == ALWrapperSessionScanResponseStatus.scanFailed) {
|
|
371
|
+
[self returnError:[NSError errorWithDomain:@"ALReactDomain" code:100 userInfo:@{NSLocalizedDescriptionKey: scanResponse.failInfo.lastError}]];
|
|
372
|
+
} else if (scanResponse.status == ALWrapperSessionScanResponseStatus.scanAborted) {
|
|
373
|
+
[self returnError:[NSError errorWithDomain:@"ALReactDomain" code:100 userInfo:@{NSLocalizedDescriptionKey: @"Canceled"}]];
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
- (void)onUIElementClicked:(nonnull ALWrapperSessionScanResultConfig *)scanResultConfig
|
|
378
|
+
uiFeedbackElementConfig:(nonnull ALUIFeedbackElementConfig *)uiFeedbackElementConfig {
|
|
379
|
+
if (scanResultConfig.callbackConfig && scanResultConfig.callbackConfig.onUIElementClickedEventName) {
|
|
380
|
+
[self sendEvent:scanResultConfig.callbackConfig.onUIElementClickedEventName
|
|
381
|
+
params:uiFeedbackElementConfig];
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
- (void)onUCRReportResponse:(nonnull ALWrapperSessionUCRReportResponse *)ucrReportResponse {
|
|
386
|
+
if (ucrReportResponse.status == ALWrapperSessionUCRReportResponseStatus.ucrReportSucceeded) {
|
|
387
|
+
ALWrapperSessionUCRReportResponseSucceed *ucrReportSucceed = ucrReportResponse.succeedInfo;
|
|
388
|
+
if (self.reportCorrectedResultResponseCallback) {
|
|
389
|
+
self.reportCorrectedResultResponseCallback(@[ucrReportSucceed.message]);
|
|
390
|
+
}
|
|
391
|
+
} else {
|
|
392
|
+
ALWrapperSessionUCRReportResponseFail *ucrReportFail = ucrReportResponse.failInfo;
|
|
393
|
+
if (self.reportCorrectedResultErrorCallback) {
|
|
394
|
+
self.reportCorrectedResultErrorCallback(@[ucrReportFail.lastError]);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
- (void)onExportCachedEventsResponse:(nonnull ALWrapperSessionExportCachedEventsResponse *)exportCachedEventsResponse {
|
|
400
|
+
if (exportCachedEventsResponse.status == ALWrapperSessionExportCachedEventsResponseStatus.exportSucceeded) {
|
|
401
|
+
ALWrapperSessionExportCachedEventsResponseSucceed *exportCachedEventsSucceed = exportCachedEventsResponse.succeedInfo;
|
|
402
|
+
if (self.wrapperSessionExportCachedEventsPromiseResolve) {
|
|
403
|
+
self.wrapperSessionExportCachedEventsPromiseResolve(@[exportCachedEventsSucceed.exportedFile]);
|
|
404
|
+
}
|
|
405
|
+
} else {
|
|
406
|
+
ALWrapperSessionExportCachedEventsResponseFail *exportCachedEventsFail = exportCachedEventsResponse.failInfo;
|
|
407
|
+
if (self.wrapperSessionExportCachedEventsPromiseReject) {
|
|
408
|
+
self.wrapperSessionExportCachedEventsPromiseReject(@"ANYLINE_ERROR", exportCachedEventsFail.lastError, nil);
|
|
409
|
+
}
|
|
343
410
|
}
|
|
344
411
|
}
|
|
345
412
|
|