From 368c80faba9eb2b1715d13f447c38e2be4102ce5 Mon Sep 17 00:00:00 2001 From: aldrichanyline <86795339+aldrichanyline@users.noreply.github.com> Date: Fri, 16 Aug 2024 12:11:43 +0200 Subject: [PATCH] Release 53.3.0 (#180) --- example/RNExampleApp/android/app/build.gradle | 2 +- .../RNExampleApp.xcodeproj/project.pbxproj | 6 ++-- example/RNExampleApp/package.json | 2 +- plugin/android/build.gradle | 2 +- .../anyline/reactnative/AnylineSDKPlugin.java | 18 +++++++++-- .../com/anyline/reactnative/ScanActivity.java | 15 +++++++++- plugin/ios/ALNFCScanViewController.h | 1 + plugin/ios/ALNFCScanViewController.m | 14 +++++++-- plugin/ios/ALPluginHelper.h | 2 +- plugin/ios/ALPluginHelper.m | 6 ++-- plugin/ios/ALPluginScanViewController.h | 1 + plugin/ios/ALPluginScanViewController.m | 24 ++++++++++++++- plugin/ios/AnylineReact.podspec | 4 +-- plugin/ios/AnylineSDKPlugin.m | 30 ++++++++++++++----- plugin/package.json | 16 +++++----- 15 files changed, 111 insertions(+), 32 deletions(-) diff --git a/example/RNExampleApp/android/app/build.gradle b/example/RNExampleApp/android/app/build.gradle index 9711e11a..c816b7c1 100644 --- a/example/RNExampleApp/android/app/build.gradle +++ b/example/RNExampleApp/android/app/build.gradle @@ -87,7 +87,7 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 5 - versionName "53.2.0" + versionName "53.3.0" multiDexEnabled true buildConfigField("boolean", "REACT_NATIVE_UNSTABLE_USE_RUNTIME_SCHEDULER_ALWAYS", (findProperty("reactNative.unstable_useRuntimeSchedulerAlways") ?: true).toString()) diff --git a/example/RNExampleApp/ios/RNExampleApp.xcodeproj/project.pbxproj b/example/RNExampleApp/ios/RNExampleApp.xcodeproj/project.pbxproj index ca514d52..05b7d29a 100644 --- a/example/RNExampleApp/ios/RNExampleApp.xcodeproj/project.pbxproj +++ b/example/RNExampleApp/ios/RNExampleApp.xcodeproj/project.pbxproj @@ -272,7 +272,7 @@ inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-RNExampleApp/Pods-RNExampleApp-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/React-Core/AccessibilityResources.bundle", - "${PODS_ROOT}/Anyline/AnylineSDK_iOS_53.2.0/Framework/AnylineResources.bundle", + "${PODS_ROOT}/Anyline/AnylineSDK_iOS_53.3.0/Framework/AnylineResources.bundle", ); name = "[CP] Copy Pods Resources"; outputPaths = ( @@ -347,7 +347,7 @@ INFOPLIST_FILE = RNExampleApp/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 53.2.0; + MARKETING_VERSION = 53.3.0; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -380,7 +380,7 @@ INFOPLIST_FILE = RNExampleApp/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 53.2.0; + MARKETING_VERSION = 53.3.0; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", diff --git a/example/RNExampleApp/package.json b/example/RNExampleApp/package.json index 3190b066..b177c647 100644 --- a/example/RNExampleApp/package.json +++ b/example/RNExampleApp/package.json @@ -1,6 +1,6 @@ { "name": "react-native-example-app", - "version": "53.2.0", + "version": "53.3.0", "private": true, "scripts": { "initProject": "yarn add expo && yarn add ../../plugin", diff --git a/plugin/android/build.gradle b/plugin/android/build.gradle index 482c9323..009aa40c 100755 --- a/plugin/android/build.gradle +++ b/plugin/android/build.gradle @@ -61,7 +61,7 @@ repositories { dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation 'io.anyline:anylinesdk:53.2.0' + implementation 'io.anyline:anylinesdk:53.3.0' implementation "com.facebook.react:react-native:+" implementation("com.google.android.material:material:1.9.0") implementation 'androidx.multidex:multidex:2.0.1' diff --git a/plugin/android/src/main/java/com/anyline/reactnative/AnylineSDKPlugin.java b/plugin/android/src/main/java/com/anyline/reactnative/AnylineSDKPlugin.java index 260ee947..62da740e 100755 --- a/plugin/android/src/main/java/com/anyline/reactnative/AnylineSDKPlugin.java +++ b/plugin/android/src/main/java/com/anyline/reactnative/AnylineSDKPlugin.java @@ -35,6 +35,7 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule implements ResultRepor public static final String REACT_CLASS = "AnylineSDKPlugin"; public static final String EXTRA_LICENSE_KEY = "EXTRA_LICENSE_KEY"; public static final String EXTRA_CONFIG_JSON = "EXTRA_CONFIG_JSON"; + public static final String EXTRA_SCANVIEW_INITIALIZATION_PARAMETERS = "EXTRA_SCANVIEW_INITIALIZATION_PARAMETERS"; public static final String EXTRA_SCAN_MODE = "EXTRA_SCAN_MODE"; public static final String EXTRA_ERROR_MESSAGE = "EXTRA_ERROR_MESSAGE"; public static final String EXTRA_OCR_CONFIG_JSON = "EXTRA_OCR_CONFIG_JSON"; @@ -53,6 +54,7 @@ class AnylineSDKPlugin extends ReactContextBaseJavaModule implements ResultRepor private Promise promise; private String returnMethod; private String config; + private String scanViewInitializationParameters; private AssetContextJsonParser assetContextJsonParser; private static WrapperConfig wrapperConfig; @@ -175,10 +177,16 @@ public void resetUpdate() { @ReactMethod public void setup(String config, String scanMode, Callback onResultReact, Callback onErrorReact) { + setupWithInitializationParameters(null, config, scanMode, onResultReact, onErrorReact); + } + + @ReactMethod + public void setupWithInitializationParameters(String initializationParameters, String config, String scanMode, Callback onResultReact, Callback onErrorReact) { onResultCallback = onResultReact; onErrorCallback = onErrorReact; this.returnMethod = "callback"; this.config = config; + this.scanViewInitializationParameters = initializationParameters; routeScanMode(scanMode); } @@ -226,9 +234,14 @@ public void exportCachedEvents(final Promise promise) { @ReactMethod public void setupPromise(String config, String scanMode, final Promise promise) { + setupPromiseWithInitializationParameters(null, config, scanMode, promise); + } + @ReactMethod + public void setupPromiseWithInitializationParameters(String initializationParameters, String config, String scanMode, final Promise promise) { this.promise = promise; this.returnMethod = "promise"; this.config = config; + this.scanViewInitializationParameters = initializationParameters; routeScanMode(scanMode); } @@ -281,13 +294,14 @@ private void scan() throws LicenseException, JSONException { if (optionsJSONObject != null) { intent.putExtra( - EXTRA_ENABLE_BARCODE_SCANNING, - optionsJSONObject.optBoolean("nativeBarcodeEnabled", false) + EXTRA_ENABLE_BARCODE_SCANNING, + optionsJSONObject.optBoolean("nativeBarcodeEnabled", false) ); } intent.putExtra(EXTRA_LICENSE_KEY, license); intent.putExtra(EXTRA_CONFIG_JSON, configObject.toString()); + intent.putExtra(EXTRA_SCANVIEW_INITIALIZATION_PARAMETERS, scanViewInitializationParameters); ResultReporter.setListener(this); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); diff --git a/plugin/android/src/main/java/com/anyline/reactnative/ScanActivity.java b/plugin/android/src/main/java/com/anyline/reactnative/ScanActivity.java index 283008a9..b52742b4 100644 --- a/plugin/android/src/main/java/com/anyline/reactnative/ScanActivity.java +++ b/plugin/android/src/main/java/com/anyline/reactnative/ScanActivity.java @@ -1,8 +1,10 @@ package com.anyline.reactnative; import static com.anyline.reactnative.AnylineSDKPlugin.EXTRA_CONFIG_JSON; +import static com.anyline.reactnative.AnylineSDKPlugin.EXTRA_SCANVIEW_INITIALIZATION_PARAMETERS; import static com.anyline.reactnative.AnylineSDKPlugin.EXTRA_ERROR_MESSAGE; import static com.anyline.reactnative.AnylineSDKPlugin.RESULT_ERROR; +import static io.anyline2.sdk.extension.ScanViewInitializationParametersExtensionKt.getScanViewInitializationParametersFromJsonObject; import android.content.Intent; import android.content.pm.ActivityInfo; @@ -29,6 +31,7 @@ import java.util.Timer; import java.util.TimerTask; +import io.anyline.plugin.config.ScanViewInitializationParameters; import io.anyline2.ScanResult; import io.anyline2.view.ScanView; import io.anyline2.viewplugin.ScanViewPlugin; @@ -98,7 +101,17 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { setupChangeOrientationButton(configJSON); setupCustomUIFeedback(configJSON); - scanView.init(configJSON); + String initializationParametersString = getIntent().getStringExtra(EXTRA_SCANVIEW_INITIALIZATION_PARAMETERS); + if (initializationParametersString != null) { + ScanViewInitializationParameters scanViewInitializationParameters = + getScanViewInitializationParametersFromJsonObject( + this, + new JSONObject(initializationParametersString)); + scanView.init(configJSON, scanViewInitializationParameters); + } + else { + scanView.init(configJSON); + } ViewPluginBase viewPluginBase = scanView.getScanViewPlugin(); diff --git a/plugin/ios/ALNFCScanViewController.h b/plugin/ios/ALNFCScanViewController.h index 6f54ceeb..22938f14 100644 --- a/plugin/ios/ALNFCScanViewController.h +++ b/plugin/ios/ALNFCScanViewController.h @@ -8,6 +8,7 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithLicensekey:(NSString *)licensekey configuration:(NSDictionary *)anylineConfig uiConfig:(ALJSONUIConfiguration *)uiConfig + initializationParamsStr:(NSString *)initializationParamsStr finished:(ALPluginCallback)callback; @end diff --git a/plugin/ios/ALNFCScanViewController.m b/plugin/ios/ALNFCScanViewController.m index ea1e1fb4..b079a9cb 100644 --- a/plugin/ios/ALNFCScanViewController.m +++ b/plugin/ios/ALNFCScanViewController.m @@ -47,6 +47,7 @@ @interface ALNFCScanViewController () "https://github.com/Anyline/anyline-ocr-react-native-module.git", :tag => "#{s.version}" } s.source_files = "*.{h,m}" - s.dependency "Anyline", "53.2.0" + s.dependency "Anyline", "53.3.0" s.dependency "React" -end \ No newline at end of file +end diff --git a/plugin/ios/AnylineSDKPlugin.m b/plugin/ios/AnylineSDKPlugin.m index d51ce85a..71a24162 100644 --- a/plugin/ios/AnylineSDKPlugin.m +++ b/plugin/ios/AnylineSDKPlugin.m @@ -27,6 +27,8 @@ @interface AnylineSDKPlugin() @property (nonatomic, copy) NSString *returnMethod; +@property (nonatomic, copy) NSString *initializationParamsStr; + @end @@ -46,15 +48,19 @@ - (UIView *)view { self.onErrorCallback = onError; self.returnMethod = @"callback"; self.config = config; - [self initView:scanMode]; + [self initView:scanMode initializationParamsStr:nil]; } RCT_EXPORT_METHOD(setup:(NSString *)config scanMode:(NSString *)scanMode onResultCallback:(RCTResponseSenderBlock)onResult onErrorCallback:(RCTResponseSenderBlock)onError) { + [self setupWithInitializationParameters:nil config:config scanMode:scanMode onResultCallback:onResult onErrorCallback:onError]; +} + +RCT_EXPORT_METHOD(setupWithInitializationParameters:(NSString * _Nullable)initializationParametersStr config:(NSString *)config scanMode:(NSString *)scanMode onResultCallback:(RCTResponseSenderBlock)onResult onErrorCallback:(RCTResponseSenderBlock)onError) { self.onResultCallback = onResult; self.onErrorCallback = onError; self.returnMethod = @"callback"; self.config = config; - [self initView:scanMode]; + [self initView:scanMode initializationParamsStr:initializationParametersStr]; } RCT_EXPORT_METHOD(setupAnylineSDK:(NSString *)licenseKey @@ -92,11 +98,16 @@ - (UIView *)view { } RCT_EXPORT_METHOD(setupPromise:(NSString *)config scanMode:(NSString *)scanMode resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { + [self setupPromiseWithInitializationParameters:nil config:config scanMode:scanMode resolver:resolve rejecter:reject]; +} + +RCT_EXPORT_METHOD(setupPromiseWithInitializationParameters:(NSString * _Nullable)initializationParametersStr config:(NSString *)configStr scanMode:(NSString *)scanMode resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { _resolveBlock = resolve; _rejectBlock = reject; self.returnMethod = @"promise"; - self.config = config; - [self initView:scanMode]; + self.config = configStr; + self.initializationParamsStr = initializationParametersStr; + [self initView:scanMode initializationParamsStr:self.initializationParamsStr]; } RCT_EXPORT_METHOD(getSDKVersion:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { @@ -134,7 +145,7 @@ - (UIView *)view { } -- (void)initView:(NSString *)scanMode { +- (void)initView:(NSString *)scanMode initializationParamsStr:(NSString * _Nullable)initializationParamsStr { NSData *data = [self.config dataUsingEncoding:NSUTF8StringEncoding]; if (!data) { [NSException raise:@"Config could not be loaded from disk" format:@"Config could not be loaded from disk"]; @@ -172,6 +183,7 @@ - (void)initView:(NSString *)scanMode { ALNFCScanViewController *nfcScanViewController = [[ALNFCScanViewController alloc] initWithLicensekey:self.appKey configuration:dictionary uiConfig:self.jsonUIConf + initializationParamsStr:initializationParamsStr finished:^(NSDictionary * _Nullable callbackObj, NSError * _Nullable error) { [self returnCallback:callbackObj andError:error]; }]; @@ -191,7 +203,9 @@ - (void)initView:(NSString *)scanMode { ALPluginScanViewController *pluginScanViewController = [[ALPluginScanViewController alloc] initWithLicensekey:self.appKey configuration:dictionary - uiConfiguration:self.jsonUIConf finished:^(NSDictionary * _Nullable callbackObj, NSError * _Nullable error) { + uiConfiguration:self.jsonUIConf + initializationParamsStr:initializationParamsStr + finished:^(NSDictionary * _Nullable callbackObj, NSError * _Nullable error) { [self returnCallback:callbackObj andError:error]; }]; @@ -204,7 +218,9 @@ - (void)initView:(NSString *)scanMode { ALPluginScanViewController *pluginScanViewController = [[ALPluginScanViewController alloc] initWithLicensekey:self.appKey configuration:dictionary - uiConfiguration:self.jsonUIConf finished:^(NSDictionary * _Nullable callbackObj, NSError * _Nullable error) { + uiConfiguration:self.jsonUIConf + initializationParamsStr:initializationParamsStr + finished:^(NSDictionary * _Nullable callbackObj, NSError * _Nullable error) { [self returnCallback:callbackObj andError:error]; }]; diff --git a/plugin/package.json b/plugin/package.json index 9c79d846..c4ea4a6e 100644 --- a/plugin/package.json +++ b/plugin/package.json @@ -1,6 +1,6 @@ { - "_from": "anyline-ocr-react-native-module@^53.2.0", - "_id": "anyline-ocr-react-native-module@^53.2.0", + "_from": "anyline-ocr-react-native-module@^53.3.0", + "_id": "anyline-ocr-react-native-module@^53.3.0", "_inBundle": false, "_integrity": "sha512-BGi9zNkSsoxXywDBIqzgBRvKUBniQOJHDKBrozZubKthZNRBAj8Ry5tW0Me0yLXt/fauME//hbC0wsenfPJZqw==", "_location": "/anyline-ocr-react-native-module", @@ -8,19 +8,19 @@ "_requested": { "type": "range", "registry": true, - "raw": "anyline-ocr-react-native-module@^53.2.0", + "raw": "anyline-ocr-react-native-module@^53.3.0", "name": "anyline-ocr-react-native-module", "escapedName": "anyline-ocr-react-native-module", - "rawSpec": "^53.2.0", + "rawSpec": "^53.3.0", "saveSpec": null, - "fetchSpec": "^53.2.0" + "fetchSpec": "^53.3.0" }, "_requiredBy": [ "/" ], - "_resolved": "https://registry.npmjs.org/anyline-ocr-react-native-module/-/anyline-ocr-react-native-module-53.2.0.tgz", + "_resolved": "https://registry.npmjs.org/anyline-ocr-react-native-module/-/anyline-ocr-react-native-module-53.3.0.tgz", "_shasum": "bacbcd260cc662244f59393ed81a6edba009b52c", - "_spec": "anyline-ocr-react-native-module@^53.2.0", + "_spec": "anyline-ocr-react-native-module@^53.3.0", "_where": "/Users/amiransari/Projects/anyline-ocr-react-native-module1/example/RNExampleApp", "bugs": { "url": "https://github.com/Anyline/anyline-ocr-react-native-module/issues" @@ -47,5 +47,5 @@ "type": "git", "url": "git+https://github.com/Anyline/anyline-ocr-react-native-module.git" }, - "version": "53.2.0" + "version": "53.3.0" }