anyline-ocr-react-native-module 55.2.0 → 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/{ios/AnylineReact.podspec → AnylineReact.podspec} +3 -3
- package/android/build.gradle +1 -3
- package/android/src/main/AndroidManifest.xml +1 -3
- package/android/src/main/java/com/anyline/reactnative/AnylineSDKPlugin.java +251 -252
- package/index.js +3 -16
- package/ios/AnylineSDKPlugin.h +4 -4
- package/ios/AnylineSDKPlugin.m +285 -207
- package/package.json +12 -2
- package/android/.gradle/7.6/checksums/checksums.lock +0 -0
- package/android/.gradle/7.6/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.6/checksums/sha1-checksums.bin +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/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.6/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.6/fileHashes/fileHashes.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/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/config.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/PipelineViewerConfig.xml +0 -6
- package/android/.idea/appInsightsSettings.xml +0 -28
- package/android/.idea/caches/deviceStreaming.xml +0 -486
- package/android/.idea/compiler.xml +0 -6
- package/android/.idea/gradle.xml +0 -19
- package/android/.idea/jarRepositories.xml +0 -30
- package/android/.idea/material_theme_project_new.xml +0 -13
- package/android/.idea/migrations.xml +0 -10
- package/android/.idea/misc.xml +0 -9
- package/android/.idea/runConfigurations.xml +0 -17
- package/android/.idea/vcs.xml +0 -6
- package/android/local.properties +0 -8
- 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,24 +1,11 @@
|
|
|
1
1
|
import {NativeModules} from 'react-native';
|
|
2
|
-
import AnylineOCR from 'anyline-ocr-react-native-module';
|
|
3
2
|
import {version as pluginVersion} from './package.json';
|
|
4
3
|
|
|
5
|
-
const
|
|
4
|
+
const AnylineOCR = NativeModules.AnylineSDKPlugin;
|
|
6
5
|
|
|
7
|
-
export default
|
|
6
|
+
export default AnylineOCR;
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
* Decrypts the License and returns the date till it's valid
|
|
11
|
-
*
|
|
12
|
-
* @param License
|
|
13
|
-
*/
|
|
14
|
-
export const getLicenseExpiryDate = (License) => {
|
|
15
|
-
const licenseString = Buffer.from(License, 'base64').toString('ascii');
|
|
16
|
-
const licenseJsonString = licenseString.substr(0, licenseString.lastIndexOf('}')+1);
|
|
17
|
-
const licenseJson = JSON.parse(licenseJsonString);
|
|
18
|
-
return licenseJson.valid;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
AnylineOCR.setPluginVersion(pluginVersion);
|
|
8
|
+
AnylineOCR.setupWrapperSession(pluginVersion);
|
|
22
9
|
|
|
23
10
|
AnylineOCR.getPluginVersion = () => {
|
|
24
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,64 +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
|
-
|
|
7
|
+
// Static instance to retain the ALWrapperSessionProvider instance
|
|
8
|
+
static ALWrapperSessionProvider *_wrapperSessionProvider;
|
|
9
|
+
// We're creating a static variable to store the last license used to initialize the SDK
|
|
10
|
+
static NSString *license;
|
|
8
11
|
|
|
9
12
|
@interface AnylineSDKPlugin()
|
|
10
13
|
|
|
11
|
-
@property (nonatomic, strong) ALViewPluginConfig *conf;
|
|
12
|
-
|
|
13
14
|
@property (nonatomic, copy) NSString *callbackId;
|
|
14
|
-
@property (nonatomic, copy) NSString *appKey;
|
|
15
|
-
@property (nonatomic, assign) BOOL nativeBarcodeScanning;
|
|
16
|
-
@property (nonatomic, strong) NSDictionary *jsonConfigDictionary;
|
|
17
|
-
@property (nonatomic, strong) NSDictionary *ocrConfigDict;
|
|
18
|
-
@property (nonatomic, strong) ALJSONUIConfiguration *jsonUIConf;
|
|
19
|
-
|
|
20
|
-
@property (nonatomic, strong) RCTResponseSenderBlock onResultCallback;
|
|
21
|
-
@property (nonatomic, strong) RCTResponseSenderBlock onErrorCallback;
|
|
22
15
|
|
|
23
16
|
@property (nonatomic, copy) NSString *config;
|
|
24
|
-
@property (nonatomic, copy) NSString *licenseKey;
|
|
25
17
|
|
|
26
18
|
@property (nonatomic, copy) NSString *returnMethod;
|
|
27
19
|
|
|
28
|
-
@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;
|
|
29
34
|
|
|
30
35
|
@end
|
|
31
36
|
|
|
32
37
|
|
|
33
38
|
@implementation AnylineSDKPlugin {
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
NSMutableArray<NSString *> *supportedRTCEventsArray;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
- (instancetype)init {
|
|
43
|
+
self = [super initWithDisabledObservation];
|
|
44
|
+
if (self) {
|
|
45
|
+
if (!_wrapperSessionProvider) {
|
|
46
|
+
// Initialize the wrapperSessionProvider static variable
|
|
47
|
+
_wrapperSessionProvider = [[ALWrapperSessionProvider alloc] init];
|
|
48
|
+
}
|
|
49
|
+
supportedRTCEventsArray = [NSMutableArray array];
|
|
50
|
+
}
|
|
51
|
+
return self;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
+ (BOOL)isInitializedWithLicenseKey:(NSString *)requestedLicense {
|
|
55
|
+
ALWrapperSessionSDKInitializationResponse *currentSdkInitializationResponse = [ALWrapperSessionProvider getCurrentSdkInitializationResponse];
|
|
56
|
+
return (license
|
|
57
|
+
&& currentSdkInitializationResponse.initialized != 0
|
|
58
|
+
&& [license isEqualToString:requestedLicense]);
|
|
36
59
|
}
|
|
37
60
|
|
|
38
61
|
RCT_EXPORT_MODULE();
|
|
62
|
+
|
|
39
63
|
- (UIView *)view {
|
|
40
64
|
return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
|
|
41
65
|
}
|
|
42
66
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
self.onResultCallback = onResult;
|
|
46
|
-
self.onErrorCallback = onError;
|
|
47
|
-
self.returnMethod = @"callback";
|
|
48
|
-
self.config = config;
|
|
49
|
-
[self initView:scanMode initializationParamsStr:nil];
|
|
67
|
+
RCT_EXPORT_METHOD(getSDKVersion:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
68
|
+
resolve(AnylineSDK.versionNumber);
|
|
50
69
|
}
|
|
51
70
|
|
|
52
|
-
RCT_EXPORT_METHOD(
|
|
53
|
-
[self
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
RCT_EXPORT_METHOD(setupWithInitializationParameters:(NSString * _Nullable)initializationParametersStr config:(NSString *)config scanMode:(NSString *)scanMode onResultCallback:(RCTResponseSenderBlock)onResult onErrorCallback:(RCTResponseSenderBlock)onError) {
|
|
57
|
-
self.onResultCallback = onResult;
|
|
58
|
-
self.onErrorCallback = onError;
|
|
59
|
-
self.returnMethod = @"callback";
|
|
60
|
-
self.config = config;
|
|
61
|
-
[self initView:scanMode initializationParamsStr:initializationParametersStr];
|
|
71
|
+
RCT_EXPORT_METHOD(setupWrapperSession:(NSString *)pluginVersion) {
|
|
72
|
+
[self setupWrapperSessionWithPluginVersion:pluginVersion];
|
|
62
73
|
}
|
|
63
74
|
|
|
64
75
|
RCT_EXPORT_METHOD(setupAnylineSDK:(NSString *)licenseKey
|
|
@@ -72,225 +83,201 @@ RCT_EXPORT_METHOD(setupAnylineSDKWithCacheConfig:(NSString *)licenseKey
|
|
|
72
83
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
73
84
|
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
74
85
|
|
|
75
|
-
|
|
76
|
-
|
|
86
|
+
self.wrapperSessionSdkInitializationResponsePromiseResolve = resolve;
|
|
87
|
+
self.wrapperSessionSdkInitializationResponsePromiseReject = reject;
|
|
77
88
|
self.returnMethod = @"promise";
|
|
78
|
-
self.licenseKey = licenseKey;
|
|
79
89
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
BOOL success = [AnylineSDK setupWithLicenseKey:licenseKey cacheConfig:cacheConfig wrapperConfig:wrapperConfig error:&error];
|
|
90
|
+
[self initSdkWithLicenseKey:licenseKey sdkAssetsFolder:nil enableOfflineCache:enableOfflineCache];
|
|
91
|
+
}
|
|
83
92
|
|
|
84
|
-
|
|
85
|
-
|
|
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
|
+
}
|
|
86
98
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
+
}
|
|
92
107
|
}
|
|
108
|
+
// not `reject`, as this will require the method to be used in a try-catch
|
|
109
|
+
resolve(nil);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
93
112
|
|
|
94
|
-
|
|
95
|
-
|
|
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];
|
|
96
116
|
}
|
|
97
117
|
|
|
98
|
-
RCT_EXPORT_METHOD(
|
|
99
|
-
[self
|
|
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];
|
|
100
120
|
}
|
|
101
121
|
|
|
102
|
-
RCT_EXPORT_METHOD(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
self.returnMethod = @"
|
|
106
|
-
|
|
107
|
-
self
|
|
108
|
-
|
|
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";
|
|
126
|
+
|
|
127
|
+
[self requestScanStartWithScanViewConfigContent:config
|
|
128
|
+
scanViewInitializationParametersString:initializationParametersStr
|
|
129
|
+
scanViewConfigPath:nil
|
|
130
|
+
scanCallbackConfigString:nil];
|
|
109
131
|
}
|
|
110
132
|
|
|
111
|
-
RCT_EXPORT_METHOD(
|
|
112
|
-
resolve
|
|
133
|
+
RCT_EXPORT_METHOD(setupPromise:(NSString *)config scanMode:(NSString *)scanMode resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
134
|
+
[self setupPromiseWithInitializationParameters:nil config:config scanMode:scanMode resolver:resolve rejecter:reject];
|
|
113
135
|
}
|
|
114
136
|
|
|
115
|
-
RCT_EXPORT_METHOD(
|
|
116
|
-
|
|
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];
|
|
117
148
|
}
|
|
118
149
|
|
|
119
|
-
RCT_EXPORT_METHOD(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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];
|
|
127
161
|
}
|
|
128
162
|
|
|
129
|
-
RCT_EXPORT_METHOD(
|
|
130
|
-
|
|
131
|
-
|
|
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];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
RCT_EXPORT_METHOD(tryStopScan:(NSString * _Nullable)scanStopRequestParams) {
|
|
179
|
+
[ALWrapperSessionProvider requestScanStopWithScanStopRequestParamsString:scanStopRequestParams];
|
|
132
180
|
}
|
|
133
181
|
|
|
134
182
|
RCT_EXPORT_METHOD(reportCorrectedResult:(NSString *)blobKey
|
|
135
183
|
correctedResult:(NSString *)correctedResult
|
|
136
184
|
onResultCallback:(RCTResponseSenderBlock)onResult
|
|
137
185
|
onErrorCallback:(RCTResponseSenderBlock)onError) {
|
|
186
|
+
self.reportCorrectedResultResponseCallback = onResult;
|
|
187
|
+
self.reportCorrectedResultErrorCallback = onError;
|
|
138
188
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
NSString *response = [ALScanResult reportCorrectedResultFromBlobKey:blobKey
|
|
142
|
-
correctedResult:correctedResult
|
|
143
|
-
apiKey:nil // apiKey should be nil
|
|
144
|
-
error:&error];
|
|
145
|
-
if (response) {
|
|
146
|
-
NSError *jsonError = nil;
|
|
147
|
-
NSData *jsonData = [response dataUsingEncoding:NSUTF8StringEncoding];
|
|
148
|
-
NSDictionary *correctedResultJson = [NSJSONSerialization JSONObjectWithData:jsonData
|
|
149
|
-
options:0
|
|
150
|
-
error:&jsonError];
|
|
151
|
-
if (jsonError) {
|
|
152
|
-
onError(@[jsonError.localizedDescription]);
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
NSNumber *correctedResultCode = [correctedResultJson objectForKey:@"code"];
|
|
157
|
-
NSString *correctedResultMessage = [correctedResultJson objectForKey:@"message"];
|
|
158
|
-
|
|
159
|
-
if ([correctedResultCode intValue] == 200) {
|
|
160
|
-
NSString *correctedResultInternalMessage = @"";
|
|
161
|
-
if (correctedResultMessage) {
|
|
162
|
-
NSError *messageJsonError = nil;
|
|
163
|
-
NSData *messageJsonData = [correctedResultMessage dataUsingEncoding:NSUTF8StringEncoding];
|
|
164
|
-
NSDictionary *messageJson = [NSJSONSerialization JSONObjectWithData:messageJsonData
|
|
165
|
-
options:0
|
|
166
|
-
error:&messageJsonError];
|
|
167
|
-
if (!messageJsonError) {
|
|
168
|
-
correctedResultInternalMessage = [messageJson objectForKey:@"message"];
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
onResult(@[correctedResultInternalMessage]);
|
|
172
|
-
} else {
|
|
173
|
-
onError(@[correctedResultMessage]);
|
|
174
|
-
}
|
|
175
|
-
} else {
|
|
176
|
-
onError(@[error.localizedDescription]);
|
|
177
|
-
}
|
|
189
|
+
[self requestUCRReportWithBlobKey:blobKey correctedResult:correctedResult];
|
|
178
190
|
}
|
|
179
191
|
|
|
180
192
|
|
|
181
193
|
RCT_EXPORT_METHOD(exportCachedEvents:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
self
|
|
194
|
+
self.wrapperSessionExportCachedEventsPromiseResolve = resolve;
|
|
195
|
+
self.wrapperSessionExportCachedEventsPromiseReject = reject;
|
|
196
|
+
[self exportCachedEvents];
|
|
197
|
+
}
|
|
185
198
|
|
|
186
|
-
NSError *error;
|
|
187
|
-
NSString *exportPath = [AnylineSDK exportCachedEvents:&error];
|
|
188
199
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
[self returnError:[NSError errorWithDomain:@"ALReactDomain" code:100 userInfo:@{NSLocalizedDescriptionKey: errorString}]];
|
|
192
|
-
} else {
|
|
193
|
-
[self returnSuccess:exportPath];
|
|
194
|
-
}
|
|
200
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
201
|
+
return supportedRTCEventsArray;
|
|
195
202
|
}
|
|
196
203
|
|
|
204
|
+
- (void)sendEvent:(NSString *)eventName
|
|
205
|
+
params:(id _Nullable) params {
|
|
197
206
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (!data) {
|
|
201
|
-
[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];
|
|
202
209
|
}
|
|
203
210
|
|
|
204
|
-
|
|
205
|
-
|
|
211
|
+
[self sendEventWithName:eventName body:params];
|
|
212
|
+
}
|
|
206
213
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
self.jsonConfigDictionary = dictionary;
|
|
214
|
+
-(NSString *)bundleRootPath {
|
|
215
|
+
NSString *rootPath = [[NSBundle mainBundle] bundlePath];
|
|
216
|
+
return rootPath;
|
|
217
|
+
}
|
|
212
218
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
219
|
+
-(NSString *)bundlePathFromScanViewConfigPath:(NSString * _Nullable)scanViewConfigPath {
|
|
220
|
+
//get root folder (ends with ...Runner.app)
|
|
221
|
+
NSString *absoluteScanViewConfigPath = [self bundleRootPath];
|
|
217
222
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
226
|
-
[[UIApplication sharedApplication] keyWindow].rootViewController.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
227
|
-
|
|
228
|
-
if ([[scanMode uppercaseString] isEqualToString:[@"scan" uppercaseString]]) {
|
|
229
|
-
ALPluginScanViewController *pluginScanViewController =
|
|
230
|
-
[[ALPluginScanViewController alloc] initWithLicensekey:self.appKey
|
|
231
|
-
configuration:dictionary
|
|
232
|
-
uiConfiguration:self.jsonUIConf
|
|
233
|
-
initializationParamsStr:initializationParamsStr
|
|
234
|
-
finished:^(NSDictionary * _Nullable callbackObj, NSError * _Nullable error) {
|
|
235
|
-
[self returnCallback:callbackObj andError:error];
|
|
236
|
-
}];
|
|
237
|
-
|
|
238
|
-
if (pluginScanViewController != nil){
|
|
239
|
-
[pluginScanViewController setModalPresentationStyle: UIModalPresentationFullScreen];
|
|
240
|
-
[[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:pluginScanViewController animated:YES completion:nil];
|
|
241
|
-
}
|
|
242
|
-
} else {
|
|
243
|
-
ALPluginScanViewController *pluginScanViewController =
|
|
244
|
-
[[ALPluginScanViewController alloc] initWithLicensekey:self.appKey
|
|
245
|
-
configuration:dictionary
|
|
246
|
-
uiConfiguration:self.jsonUIConf
|
|
247
|
-
initializationParamsStr:initializationParamsStr
|
|
248
|
-
finished:^(NSDictionary * _Nullable callbackObj, NSError * _Nullable error) {
|
|
249
|
-
[self returnCallback:callbackObj andError:error];
|
|
250
|
-
}];
|
|
251
|
-
|
|
252
|
-
if (pluginScanViewController != nil){
|
|
253
|
-
[pluginScanViewController setModalPresentationStyle: UIModalPresentationFullScreen];
|
|
254
|
-
[[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:pluginScanViewController animated:YES completion:nil];
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
});
|
|
223
|
+
if (scanViewConfigPath) {
|
|
224
|
+
//append scanViewConfigPath
|
|
225
|
+
absoluteScanViewConfigPath = [absoluteScanViewConfigPath stringByAppendingPathComponent:scanViewConfigPath];
|
|
226
|
+
}
|
|
227
|
+
return absoluteScanViewConfigPath;
|
|
228
|
+
}
|
|
258
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];
|
|
259
235
|
}
|
|
260
236
|
|
|
261
|
-
|
|
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];
|
|
262
244
|
|
|
263
|
-
|
|
264
|
-
|
|
245
|
+
[ALWrapperSessionProvider
|
|
246
|
+
requestSdkInitializationWithInitializationRequestParamsString:[wrapperSessionSdkInitializationRequestJson asJSONString]];
|
|
247
|
+
}
|
|
265
248
|
|
|
249
|
+
- (void)requestScanStartWithScanViewConfigContent:(NSString *)scanViewConfigContent
|
|
250
|
+
scanViewInitializationParametersString:(NSString * _Nullable)scanViewInitializationParametersString
|
|
251
|
+
scanViewConfigPath:(NSString * _Nullable)scanViewConfigPath
|
|
252
|
+
scanCallbackConfigString:(NSString * _Nullable)scanCallbackConfigString {
|
|
266
253
|
NSError *error;
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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];
|
|
273
265
|
} else {
|
|
274
|
-
|
|
266
|
+
NSDictionary *wrapperSessionScanStartRequestDict = [wrapperSessionScanStartRequest toJSONDictionary];
|
|
267
|
+
[ALWrapperSessionProvider requestScanStartWithScanStartRequestParamsString:[wrapperSessionScanStartRequestDict asJSONString]];
|
|
275
268
|
}
|
|
276
|
-
[self returnSuccess:resultJson];
|
|
277
269
|
}
|
|
278
270
|
|
|
279
|
-
- (void)
|
|
280
|
-
|
|
281
|
-
}
|
|
271
|
+
- (void)requestUCRReportWithBlobKey:(NSString *)blobKey
|
|
272
|
+
correctedResult:(NSString *)correctedResult {
|
|
282
273
|
|
|
283
|
-
|
|
284
|
-
|
|
274
|
+
ALWrapperSessionUCRReportRequest *wrapperSessionSdkInitializationRequest = [ALLegacyPluginHelper ucrReportRequestWithBlobKey:blobKey
|
|
275
|
+
correctedResult:correctedResult];
|
|
276
|
+
[ALWrapperSessionProvider requestUCRReport:wrapperSessionSdkInitializationRequest];
|
|
285
277
|
}
|
|
286
278
|
|
|
287
|
-
-
|
|
288
|
-
|
|
289
|
-
NSArray *possibleScanModes = @[@"DOCUMENT", @"MRZ", @"BARCODE", @"LICENSE_PLATE", @"LICENSE_PLATE_US", @"ANYLINE_OCR", @"TIRE", @"ANALOG_METER", @"DIGITAL_METER", @"AUTO_ANALOG_DIGITAL_METER",
|
|
290
|
-
@"DIAL_METER", @"SERIAL_NUMBER", @"HEAT_METER_4", @"HEAT_METER_5", @"HEAT_METER_6", @"DOT_MATRIX_METER"];
|
|
291
|
-
|
|
292
|
-
return [possibleScanModes containsObject: [scanMode uppercaseString]];
|
|
293
|
-
|
|
279
|
+
-(void)exportCachedEvents {
|
|
280
|
+
[ALWrapperSessionProvider requestExportCachedEvents];
|
|
294
281
|
}
|
|
295
282
|
|
|
296
283
|
- (void)returnCallback:(id _Nullable)callbackObj andError:(NSError * _Nullable)error {
|
|
@@ -312,17 +299,108 @@ RCT_EXPORT_METHOD(exportCachedEvents:(RCTPromiseResolveBlock)resolve rejecter:(R
|
|
|
312
299
|
|
|
313
300
|
- (void)returnSuccess:(NSString *)result {
|
|
314
301
|
if ([self.returnMethod isEqualToString:@"callback"]) {
|
|
315
|
-
self.
|
|
302
|
+
self.scanResponseResultCallback(@[result]);
|
|
316
303
|
} else if ([self.returnMethod isEqualToString:@"promise"]) {
|
|
317
|
-
|
|
304
|
+
if (self.wrapperSessionScanResponsePromiseResolve) {
|
|
305
|
+
self.wrapperSessionScanResponsePromiseResolve(result);
|
|
306
|
+
}
|
|
307
|
+
self.wrapperSessionScanResponsePromiseResolve = nil;
|
|
318
308
|
}
|
|
319
309
|
}
|
|
320
310
|
|
|
321
311
|
- (void)returnError:(NSError *)error {
|
|
322
312
|
if ([self.returnMethod isEqualToString:@"callback"]) {
|
|
323
|
-
self.
|
|
313
|
+
self.scanResponseErrorCallback(@[error]);
|
|
324
314
|
} else if ([self.returnMethod isEqualToString:@"promise"]) {
|
|
325
|
-
|
|
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
|
+
}
|
|
326
404
|
}
|
|
327
405
|
}
|
|
328
406
|
|