anyline-ocr-react-native-module 55.2.1 → 55.5.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 +241 -254
- package/index.js +1 -15
- package/ios/AnylineSDKPlugin.h +4 -4
- package/ios/AnylineSDKPlugin.m +275 -214
- 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,75 @@
|
|
|
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
|
-
ALWrapperConfig *wrapperConfig = nil;
|
|
13
|
-
|
|
14
12
|
@interface AnylineSDKPlugin()
|
|
15
13
|
|
|
16
14
|
@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
15
|
|
|
25
16
|
@property (nonatomic, copy) NSString *config;
|
|
26
17
|
|
|
27
18
|
@property (nonatomic, copy) NSString *returnMethod;
|
|
28
19
|
|
|
29
|
-
@property (nonatomic,
|
|
20
|
+
@property (nonatomic, strong) RCTPromiseResolveBlock wrapperSessionSdkInitializationResponsePromiseResolve;
|
|
21
|
+
@property (nonatomic, strong) RCTPromiseRejectBlock wrapperSessionSdkInitializationResponsePromiseReject;
|
|
22
|
+
|
|
23
|
+
@property (nonatomic, strong) RCTPromiseResolveBlock wrapperSessionScanResponsePromiseResolve;
|
|
24
|
+
@property (nonatomic, strong) RCTPromiseRejectBlock wrapperSessionScanResponsePromiseReject;
|
|
25
|
+
|
|
26
|
+
@property (nonatomic, strong) RCTResponseSenderBlock scanResponseResultCallback;
|
|
27
|
+
@property (nonatomic, strong) RCTResponseSenderBlock scanResponseErrorCallback;
|
|
28
|
+
|
|
29
|
+
@property (nonatomic, strong) RCTPromiseResolveBlock wrapperSessionExportCachedEventsPromiseResolve;
|
|
30
|
+
@property (nonatomic, strong) RCTPromiseRejectBlock wrapperSessionExportCachedEventsPromiseReject;
|
|
31
|
+
|
|
32
|
+
@property (nonatomic, strong) RCTResponseSenderBlock reportCorrectedResultResponseCallback;
|
|
33
|
+
@property (nonatomic, strong) RCTResponseSenderBlock reportCorrectedResultErrorCallback;
|
|
30
34
|
|
|
31
35
|
@end
|
|
32
36
|
|
|
33
37
|
|
|
34
38
|
@implementation AnylineSDKPlugin {
|
|
35
|
-
|
|
36
|
-
RCTPromiseRejectBlock _rejectBlock;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
+ (BOOL)isInitializedWithLicenseKey:(NSString *)requestedLicense {
|
|
40
|
-
return (license && [AnylineSDK isInitialized] && [license isEqualToString:requestedLicense]);
|
|
39
|
+
NSMutableArray<NSString *> *supportedRTCEventsArray;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
- (instancetype)init {
|
|
44
|
-
self = [super
|
|
43
|
+
self = [super initWithDisabledObservation];
|
|
45
44
|
if (self) {
|
|
46
|
-
if (!
|
|
47
|
-
// Initialize the
|
|
48
|
-
|
|
45
|
+
if (!_wrapperSessionProvider) {
|
|
46
|
+
// Initialize the wrapperSessionProvider static variable
|
|
47
|
+
_wrapperSessionProvider = [[ALWrapperSessionProvider alloc] init];
|
|
49
48
|
}
|
|
49
|
+
supportedRTCEventsArray = [NSMutableArray array];
|
|
50
50
|
}
|
|
51
51
|
return self;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
+ (BOOL)isInitializedWithLicenseKey:(NSString *)requestedLicense {
|
|
55
|
+
ALWrapperSessionSDKInitializationResponse *currentSdkInitializationResponse = [ALWrapperSessionProvider getCurrentSdkInitializationResponse];
|
|
56
|
+
return (license
|
|
57
|
+
&& currentSdkInitializationResponse.initialized != 0
|
|
58
|
+
&& [license isEqualToString:requestedLicense]);
|
|
59
|
+
}
|
|
60
|
+
|
|
54
61
|
RCT_EXPORT_MODULE();
|
|
62
|
+
|
|
55
63
|
- (UIView *)view {
|
|
56
64
|
return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
|
|
57
65
|
}
|
|
58
66
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
self.onResultCallback = onResult;
|
|
62
|
-
self.onErrorCallback = onError;
|
|
63
|
-
self.returnMethod = @"callback";
|
|
64
|
-
self.config = config;
|
|
65
|
-
[self initView:scanMode initializationParamsStr:nil];
|
|
67
|
+
RCT_EXPORT_METHOD(getSDKVersion:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
68
|
+
resolve(AnylineSDK.versionNumber);
|
|
66
69
|
}
|
|
67
70
|
|
|
68
|
-
RCT_EXPORT_METHOD(
|
|
69
|
-
[self
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
RCT_EXPORT_METHOD(setupWithInitializationParameters:(NSString * _Nullable)initializationParametersStr config:(NSString *)config scanMode:(NSString *)scanMode onResultCallback:(RCTResponseSenderBlock)onResult onErrorCallback:(RCTResponseSenderBlock)onError) {
|
|
73
|
-
self.onResultCallback = onResult;
|
|
74
|
-
self.onErrorCallback = onError;
|
|
75
|
-
self.returnMethod = @"callback";
|
|
76
|
-
self.config = config;
|
|
77
|
-
[self initView:scanMode initializationParamsStr:initializationParametersStr];
|
|
71
|
+
RCT_EXPORT_METHOD(setupWrapperSession:(NSString *)pluginVersion) {
|
|
72
|
+
[self setupWrapperSessionWithPluginVersion:pluginVersion];
|
|
78
73
|
}
|
|
79
74
|
|
|
80
75
|
RCT_EXPORT_METHOD(setupAnylineSDK:(NSString *)licenseKey
|
|
@@ -88,226 +83,201 @@ RCT_EXPORT_METHOD(setupAnylineSDKWithCacheConfig:(NSString *)licenseKey
|
|
|
88
83
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
89
84
|
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
90
85
|
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
self.wrapperSessionSdkInitializationResponsePromiseResolve = resolve;
|
|
87
|
+
self.wrapperSessionSdkInitializationResponsePromiseReject = reject;
|
|
93
88
|
self.returnMethod = @"promise";
|
|
94
89
|
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
[self initSdkWithLicenseKey:licenseKey sdkAssetsFolder:nil enableOfflineCache:enableOfflineCache];
|
|
91
|
+
}
|
|
97
92
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
93
|
+
RCT_EXPORT_METHOD(isInitialized:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
94
|
+
ALWrapperSessionSDKInitializationResponse *currentSdkInitializationResponse = [ALWrapperSessionProvider getCurrentSdkInitializationResponse];
|
|
95
|
+
BOOL isInitialized = (currentSdkInitializationResponse.initialized != 0);
|
|
96
|
+
resolve(@(isInitialized));
|
|
97
|
+
}
|
|
102
98
|
|
|
103
|
-
|
|
99
|
+
RCT_EXPORT_METHOD(licenseKeyExpiryDate:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
100
|
+
ALWrapperSessionSDKInitializationResponse *currentSdkInitializationResponse = [ALWrapperSessionProvider getCurrentSdkInitializationResponse];
|
|
101
|
+
if (currentSdkInitializationResponse.initialized != 0) {
|
|
102
|
+
ALWrapperSessionSDKInitializationResponseInitialized *sdkInitializationResponseInitialized = currentSdkInitializationResponse.succeedInfo;
|
|
103
|
+
if (sdkInitializationResponseInitialized) {
|
|
104
|
+
resolve(sdkInitializationResponseInitialized.expiryDate);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// not `reject`, as this will require the method to be used in a try-catch
|
|
109
|
+
resolve(nil);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
104
112
|
|
|
105
|
-
|
|
113
|
+
// Deprecated
|
|
114
|
+
RCT_EXPORT_METHOD(setupScanViewWithConfigJson:(NSString *)config scanMode:(NSString *)scanMode onResultCallback:(RCTResponseSenderBlock)onResult onErrorCallback:(RCTResponseSenderBlock)onError) {
|
|
115
|
+
[self setupWithInitializationParameters:nil config:config scanMode:scanMode onResultCallback:onResult onErrorCallback:onError];
|
|
116
|
+
}
|
|
106
117
|
|
|
107
|
-
|
|
108
|
-
|
|
118
|
+
RCT_EXPORT_METHOD(setup:(NSString *)config scanMode:(NSString *)scanMode onResultCallback:(RCTResponseSenderBlock)onResult onErrorCallback:(RCTResponseSenderBlock)onError) {
|
|
119
|
+
[self setupWithInitializationParameters:nil config:config scanMode:scanMode onResultCallback:onResult onErrorCallback:onError];
|
|
120
|
+
}
|
|
109
121
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
122
|
+
RCT_EXPORT_METHOD(setupWithInitializationParameters:(NSString * _Nullable)initializationParametersStr config:(NSString *)config scanMode:(NSString *)scanMode onResultCallback:(RCTResponseSenderBlock)onResult onErrorCallback:(RCTResponseSenderBlock)onError) {
|
|
123
|
+
self.scanResponseResultCallback = onResult;
|
|
124
|
+
self.scanResponseErrorCallback = onError;
|
|
125
|
+
self.returnMethod = @"callback";
|
|
116
126
|
|
|
117
|
-
|
|
118
|
-
|
|
127
|
+
[self requestScanStartWithScanViewConfigContent:config
|
|
128
|
+
scanViewInitializationParametersString:initializationParametersStr
|
|
129
|
+
scanViewConfigPath:nil
|
|
130
|
+
scanCallbackConfigString:nil];
|
|
119
131
|
}
|
|
120
132
|
|
|
121
133
|
RCT_EXPORT_METHOD(setupPromise:(NSString *)config scanMode:(NSString *)scanMode resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
122
134
|
[self setupPromiseWithInitializationParameters:nil config:config scanMode:scanMode resolver:resolve rejecter:reject];
|
|
123
135
|
}
|
|
124
136
|
|
|
125
|
-
RCT_EXPORT_METHOD(setupPromiseWithInitializationParameters:(NSString * _Nullable)initializationParametersStr
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
self
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
137
|
+
RCT_EXPORT_METHOD(setupPromiseWithInitializationParameters:(NSString * _Nullable)initializationParametersStr
|
|
138
|
+
config:(NSString *)configStr
|
|
139
|
+
scanMode:(NSString *)scanMode
|
|
140
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
141
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
142
|
+
[self setupPromiseWithInitializationParametersAndScanCallbackConfig:initializationParametersStr
|
|
143
|
+
config:configStr
|
|
144
|
+
scanMode:scanMode
|
|
145
|
+
scanCallbackConfigString:nil
|
|
146
|
+
resolver:resolve
|
|
147
|
+
rejecter:reject];
|
|
136
148
|
}
|
|
137
149
|
|
|
138
|
-
RCT_EXPORT_METHOD(
|
|
139
|
-
|
|
150
|
+
RCT_EXPORT_METHOD(setupPromiseWithScanCallbackConfig:(NSString *)configStr
|
|
151
|
+
scanMode:(NSString *)scanMode
|
|
152
|
+
scanCallbackConfigString:(NSString *)scanCallbackConfigString
|
|
153
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
154
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
155
|
+
[self setupPromiseWithInitializationParametersAndScanCallbackConfig:nil
|
|
156
|
+
config:configStr
|
|
157
|
+
scanMode:scanMode
|
|
158
|
+
scanCallbackConfigString:scanCallbackConfigString
|
|
159
|
+
resolver:resolve
|
|
160
|
+
rejecter:reject];
|
|
140
161
|
}
|
|
141
162
|
|
|
142
|
-
RCT_EXPORT_METHOD(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
163
|
+
RCT_EXPORT_METHOD(setupPromiseWithInitializationParametersAndScanCallbackConfig:(NSString * _Nullable)initializationParametersStr
|
|
164
|
+
config:(NSString *)configStr
|
|
165
|
+
scanMode:(NSString *)scanMode
|
|
166
|
+
scanCallbackConfigString:(NSString * _Nullable)scanCallbackConfigString
|
|
167
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
168
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
169
|
+
self.wrapperSessionScanResponsePromiseResolve = resolve;
|
|
170
|
+
self.wrapperSessionScanResponsePromiseReject = reject;
|
|
171
|
+
self.returnMethod = @"promise";
|
|
172
|
+
[self requestScanStartWithScanViewConfigContent:configStr
|
|
173
|
+
scanViewInitializationParametersString:initializationParametersStr
|
|
174
|
+
scanViewConfigPath:nil
|
|
175
|
+
scanCallbackConfigString:scanCallbackConfigString];
|
|
150
176
|
}
|
|
151
177
|
|
|
152
|
-
RCT_EXPORT_METHOD(
|
|
153
|
-
|
|
154
|
-
resolve(@(isInitialized));
|
|
178
|
+
RCT_EXPORT_METHOD(tryStopScan:(NSString * _Nullable)scanStopRequestParams) {
|
|
179
|
+
[ALWrapperSessionProvider requestScanStopWithScanStopRequestParamsString:scanStopRequestParams];
|
|
155
180
|
}
|
|
156
181
|
|
|
157
182
|
RCT_EXPORT_METHOD(reportCorrectedResult:(NSString *)blobKey
|
|
158
183
|
correctedResult:(NSString *)correctedResult
|
|
159
184
|
onResultCallback:(RCTResponseSenderBlock)onResult
|
|
160
185
|
onErrorCallback:(RCTResponseSenderBlock)onError) {
|
|
186
|
+
self.reportCorrectedResultResponseCallback = onResult;
|
|
187
|
+
self.reportCorrectedResultErrorCallback = onError;
|
|
161
188
|
|
|
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
|
-
}
|
|
189
|
+
[self requestUCRReportWithBlobKey:blobKey correctedResult:correctedResult];
|
|
201
190
|
}
|
|
202
191
|
|
|
203
192
|
|
|
204
193
|
RCT_EXPORT_METHOD(exportCachedEvents:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
self
|
|
194
|
+
self.wrapperSessionExportCachedEventsPromiseResolve = resolve;
|
|
195
|
+
self.wrapperSessionExportCachedEventsPromiseReject = reject;
|
|
196
|
+
[self exportCachedEvents];
|
|
197
|
+
}
|
|
208
198
|
|
|
209
|
-
NSError *error;
|
|
210
|
-
NSString *exportPath = [AnylineSDK exportCachedEvents:&error];
|
|
211
199
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
[self returnError:[NSError errorWithDomain:@"ALReactDomain" code:100 userInfo:@{NSLocalizedDescriptionKey: errorString}]];
|
|
215
|
-
} else {
|
|
216
|
-
[self returnSuccess:exportPath];
|
|
217
|
-
}
|
|
200
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
201
|
+
return supportedRTCEventsArray;
|
|
218
202
|
}
|
|
219
203
|
|
|
204
|
+
- (void)sendEvent:(NSString *)eventName
|
|
205
|
+
params:(id _Nullable) params {
|
|
220
206
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
if (!data) {
|
|
224
|
-
[NSException raise:@"Config could not be loaded from disk" format:@"Config could not be loaded from disk"];
|
|
207
|
+
if (![supportedRTCEventsArray containsObject:eventName]) {
|
|
208
|
+
[supportedRTCEventsArray addObject:eventName];
|
|
225
209
|
}
|
|
226
210
|
|
|
227
|
-
|
|
228
|
-
|
|
211
|
+
[self sendEventWithName:eventName body:params];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
-(NSString *)bundleRootPath {
|
|
215
|
+
NSString *rootPath = [[NSBundle mainBundle] bundlePath];
|
|
216
|
+
return rootPath;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
-(NSString *)bundlePathFromScanViewConfigPath:(NSString * _Nullable)scanViewConfigPath {
|
|
220
|
+
//get root folder (ends with ...Runner.app)
|
|
221
|
+
NSString *absoluteScanViewConfigPath = [self bundleRootPath];
|
|
229
222
|
|
|
230
|
-
if (
|
|
231
|
-
|
|
223
|
+
if (scanViewConfigPath) {
|
|
224
|
+
//append scanViewConfigPath
|
|
225
|
+
absoluteScanViewConfigPath = [absoluteScanViewConfigPath stringByAppendingPathComponent:scanViewConfigPath];
|
|
232
226
|
}
|
|
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
|
-
});
|
|
227
|
+
return absoluteScanViewConfigPath;
|
|
228
|
+
}
|
|
275
229
|
|
|
230
|
+
- (void)setupWrapperSessionWithPluginVersion:(NSString *)pluginVersion {
|
|
231
|
+
// Setup wrapper session with this view controller as delegate
|
|
232
|
+
ALWrapperConfig *wrapperConfig = [ALWrapperConfig reactNative:pluginVersion];
|
|
233
|
+
[ALWrapperSessionProvider setupWrapperSessionWithWrapperInfo:wrapperConfig
|
|
234
|
+
wrapperSessionClient:self];
|
|
276
235
|
}
|
|
277
236
|
|
|
278
|
-
|
|
237
|
+
- (void)initSdkWithLicenseKey:(NSString *)sdkLicenseKey
|
|
238
|
+
sdkAssetsFolder: (NSString *)sdkAssetsFolder
|
|
239
|
+
enableOfflineCache: (BOOL)enableOfflineCache {
|
|
240
|
+
NSDictionary *wrapperSessionSdkInitializationRequestJson = [ALLegacyPluginHelper
|
|
241
|
+
sdkInitializationRequestJsonWithLicenseKey:sdkLicenseKey
|
|
242
|
+
enableOfflineCache:enableOfflineCache
|
|
243
|
+
assetPathPrefix:sdkAssetsFolder];
|
|
279
244
|
|
|
280
|
-
|
|
281
|
-
|
|
245
|
+
[ALWrapperSessionProvider
|
|
246
|
+
requestSdkInitializationWithInitializationRequestParamsString:[wrapperSessionSdkInitializationRequestJson asJSONString]];
|
|
247
|
+
}
|
|
282
248
|
|
|
249
|
+
- (void)requestScanStartWithScanViewConfigContent:(NSString *)scanViewConfigContent
|
|
250
|
+
scanViewInitializationParametersString:(NSString * _Nullable)scanViewInitializationParametersString
|
|
251
|
+
scanViewConfigPath:(NSString * _Nullable)scanViewConfigPath
|
|
252
|
+
scanCallbackConfigString:(NSString * _Nullable)scanCallbackConfigString {
|
|
283
253
|
NSError *error;
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
254
|
+
BOOL shouldReturnImages = true;
|
|
255
|
+
|
|
256
|
+
ALWrapperSessionScanStartRequest *wrapperSessionScanStartRequest = [ALLegacyPluginHelper
|
|
257
|
+
scanStartRequestWithScanViewConfigContentString:scanViewConfigContent
|
|
258
|
+
scanViewInitializationParametersString:scanViewInitializationParametersString
|
|
259
|
+
scanViewConfigPath:[self bundlePathFromScanViewConfigPath:scanViewConfigPath]
|
|
260
|
+
scanResultCallbackConfigString:scanCallbackConfigString
|
|
261
|
+
shouldReturnImages:shouldReturnImages
|
|
262
|
+
error:&error];
|
|
263
|
+
if (error) {
|
|
264
|
+
[self returnError:error];
|
|
290
265
|
} else {
|
|
291
|
-
|
|
266
|
+
NSDictionary *wrapperSessionScanStartRequestDict = [wrapperSessionScanStartRequest toJSONDictionary];
|
|
267
|
+
[ALWrapperSessionProvider requestScanStartWithScanStartRequestParamsString:[wrapperSessionScanStartRequestDict asJSONString]];
|
|
292
268
|
}
|
|
293
|
-
[self returnSuccess:resultJson];
|
|
294
269
|
}
|
|
295
270
|
|
|
296
|
-
- (void)
|
|
297
|
-
|
|
298
|
-
}
|
|
271
|
+
- (void)requestUCRReportWithBlobKey:(NSString *)blobKey
|
|
272
|
+
correctedResult:(NSString *)correctedResult {
|
|
299
273
|
|
|
300
|
-
|
|
301
|
-
|
|
274
|
+
ALWrapperSessionUCRReportRequest *wrapperSessionSdkInitializationRequest = [ALLegacyPluginHelper ucrReportRequestWithBlobKey:blobKey
|
|
275
|
+
correctedResult:correctedResult];
|
|
276
|
+
[ALWrapperSessionProvider requestUCRReport:wrapperSessionSdkInitializationRequest];
|
|
302
277
|
}
|
|
303
278
|
|
|
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
|
-
|
|
279
|
+
-(void)exportCachedEvents {
|
|
280
|
+
[ALWrapperSessionProvider requestExportCachedEvents];
|
|
311
281
|
}
|
|
312
282
|
|
|
313
283
|
- (void)returnCallback:(id _Nullable)callbackObj andError:(NSError * _Nullable)error {
|
|
@@ -329,17 +299,108 @@ RCT_EXPORT_METHOD(exportCachedEvents:(RCTPromiseResolveBlock)resolve rejecter:(R
|
|
|
329
299
|
|
|
330
300
|
- (void)returnSuccess:(NSString *)result {
|
|
331
301
|
if ([self.returnMethod isEqualToString:@"callback"]) {
|
|
332
|
-
self.
|
|
302
|
+
self.scanResponseResultCallback(@[result]);
|
|
333
303
|
} else if ([self.returnMethod isEqualToString:@"promise"]) {
|
|
334
|
-
|
|
304
|
+
if (self.wrapperSessionScanResponsePromiseResolve) {
|
|
305
|
+
self.wrapperSessionScanResponsePromiseResolve(result);
|
|
306
|
+
}
|
|
307
|
+
self.wrapperSessionScanResponsePromiseResolve = nil;
|
|
335
308
|
}
|
|
336
309
|
}
|
|
337
310
|
|
|
338
311
|
- (void)returnError:(NSError *)error {
|
|
339
312
|
if ([self.returnMethod isEqualToString:@"callback"]) {
|
|
340
|
-
self.
|
|
313
|
+
self.scanResponseErrorCallback(@[error]);
|
|
341
314
|
} else if ([self.returnMethod isEqualToString:@"promise"]) {
|
|
342
|
-
|
|
315
|
+
if (self.wrapperSessionScanResponsePromiseReject) {
|
|
316
|
+
self.wrapperSessionScanResponsePromiseReject(@"ANYLINE_ERROR", error.localizedDescription, error);
|
|
317
|
+
}
|
|
318
|
+
self.wrapperSessionScanResponsePromiseReject = nil;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
#pragma mark - ALWrapperSessionClientDelegate
|
|
323
|
+
|
|
324
|
+
- (nullable UIViewController *)getTopViewController {
|
|
325
|
+
UIViewController *topViewController = RCTPresentedViewController();
|
|
326
|
+
if (!topViewController) {
|
|
327
|
+
topViewController = [[UIApplication sharedApplication] keyWindow].rootViewController;
|
|
328
|
+
return topViewController;
|
|
329
|
+
}
|
|
330
|
+
return nil;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
- (void)onSdkInitializationResponse:(nonnull ALWrapperSessionSDKInitializationResponse *)initializationResponse {
|
|
334
|
+
if (initializationResponse.initialized) {
|
|
335
|
+
self.wrapperSessionSdkInitializationResponsePromiseResolve(@"success");
|
|
336
|
+
} else {
|
|
337
|
+
self.wrapperSessionSdkInitializationResponsePromiseReject(@"ANYLINE_ERROR", [[initializationResponse toJSONDictionary] asJSONString], nil);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
- (void)onScanResults:(nonnull ALWrapperSessionScanResultsResponse *)scanResultsResponse {
|
|
342
|
+
ALWrapperSessionScanResultConfig *scanResultConfig = scanResultsResponse.scanResultConfig;
|
|
343
|
+
NSArray<ALExportedScanResult *> *exportedScanResultsArray = (NSArray<ALExportedScanResult *> *) scanResultsResponse.exportedScanResults;
|
|
344
|
+
ALWrapperSessionScanResultExtraInfo *scanResultExtraInfo = scanResultsResponse.scanResultExtraInfo;
|
|
345
|
+
|
|
346
|
+
NSError *error;
|
|
347
|
+
NSString *resultsWithImagePathString = [ALLegacyPluginHelper scanResultsWithImagePathFromExportedScanResults:exportedScanResultsArray
|
|
348
|
+
viewPluginType:scanResultExtraInfo.viewPluginType
|
|
349
|
+
error:&error];
|
|
350
|
+
|
|
351
|
+
if (scanResultConfig.callbackConfig && scanResultConfig.callbackConfig.onResultEventName) {
|
|
352
|
+
[self sendEvent:scanResultConfig.callbackConfig.onResultEventName params:resultsWithImagePathString];
|
|
353
|
+
} else {
|
|
354
|
+
[self returnSuccess:resultsWithImagePathString];
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
- (void)onScanResponse:(nonnull ALWrapperSessionScanResponse *)scanResponse {
|
|
359
|
+
if (scanResponse.status == ALWrapperSessionScanResponseStatus.scanSucceeded) {
|
|
360
|
+
ALWrapperSessionScanResultConfig *scanResultConfig = scanResponse.scanResultConfig;
|
|
361
|
+
if (scanResultConfig.callbackConfig && scanResultConfig.callbackConfig.onResultEventName) {
|
|
362
|
+
[self returnSuccess:@""];
|
|
363
|
+
}
|
|
364
|
+
} else if (scanResponse.status == ALWrapperSessionScanResponseStatus.scanFailed) {
|
|
365
|
+
[self returnError:[NSError errorWithDomain:@"ALReactDomain" code:100 userInfo:@{NSLocalizedDescriptionKey: scanResponse.failInfo.lastError}]];
|
|
366
|
+
} else if (scanResponse.status == ALWrapperSessionScanResponseStatus.scanAborted) {
|
|
367
|
+
[self returnError:[NSError errorWithDomain:@"ALReactDomain" code:100 userInfo:@{NSLocalizedDescriptionKey: @"Canceled"}]];
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
- (void)onUIElementClicked:(nonnull ALWrapperSessionScanResultConfig *)scanResultConfig
|
|
372
|
+
uiFeedbackElementConfig:(nonnull ALUIFeedbackElementConfig *)uiFeedbackElementConfig {
|
|
373
|
+
if (scanResultConfig.callbackConfig && scanResultConfig.callbackConfig.onUIElementClickedEventName) {
|
|
374
|
+
[self sendEvent:scanResultConfig.callbackConfig.onUIElementClickedEventName
|
|
375
|
+
params:uiFeedbackElementConfig];
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
- (void)onUCRReportResponse:(nonnull ALWrapperSessionUCRReportResponse *)ucrReportResponse {
|
|
380
|
+
if (ucrReportResponse.status == ALWrapperSessionUCRReportResponseStatus.ucrReportSucceeded) {
|
|
381
|
+
ALWrapperSessionUCRReportResponseSucceed *ucrReportSucceed = ucrReportResponse.succeedInfo;
|
|
382
|
+
if (self.reportCorrectedResultResponseCallback) {
|
|
383
|
+
self.reportCorrectedResultResponseCallback(@[ucrReportSucceed.message]);
|
|
384
|
+
}
|
|
385
|
+
} else {
|
|
386
|
+
ALWrapperSessionUCRReportResponseFail *ucrReportFail = ucrReportResponse.failInfo;
|
|
387
|
+
if (self.reportCorrectedResultErrorCallback) {
|
|
388
|
+
self.reportCorrectedResultErrorCallback(@[ucrReportFail.lastError]);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
- (void)onExportCachedEventsResponse:(nonnull ALWrapperSessionExportCachedEventsResponse *)exportCachedEventsResponse {
|
|
394
|
+
if (exportCachedEventsResponse.status == ALWrapperSessionExportCachedEventsResponseStatus.exportSucceeded) {
|
|
395
|
+
ALWrapperSessionExportCachedEventsResponseSucceed *exportCachedEventsSucceed = exportCachedEventsResponse.succeedInfo;
|
|
396
|
+
if (self.wrapperSessionExportCachedEventsPromiseResolve) {
|
|
397
|
+
self.wrapperSessionExportCachedEventsPromiseResolve(@[exportCachedEventsSucceed.exportedFile]);
|
|
398
|
+
}
|
|
399
|
+
} else {
|
|
400
|
+
ALWrapperSessionExportCachedEventsResponseFail *exportCachedEventsFail = exportCachedEventsResponse.failInfo;
|
|
401
|
+
if (self.wrapperSessionExportCachedEventsPromiseReject) {
|
|
402
|
+
self.wrapperSessionExportCachedEventsPromiseReject(@"ANYLINE_ERROR", exportCachedEventsFail.lastError, nil);
|
|
403
|
+
}
|
|
343
404
|
}
|
|
344
405
|
}
|
|
345
406
|
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|