From d2c9dea7b2796d1bad3bc158c5a8d6dd1ab1d6ad Mon Sep 17 00:00:00 2001 From: rohitlokhandeanyline Date: Tue, 19 Nov 2024 17:13:47 +0530 Subject: [PATCH] Release 54.4.0 (#185) --- example/RNExampleApp/android/app/build.gradle | 2 +- .../RNExampleApp.xcodeproj/project.pbxproj | 6 ++--- example/RNExampleApp/package.json | 2 +- example/RNExampleApp/src/index.js | 6 +++++ plugin/android/build.gradle | 2 +- .../anyline/reactnative/AnylineSDKPlugin.java | 25 ++++++++++--------- plugin/ios/AnylineReact.podspec | 2 +- plugin/ios/AnylineSDKPlugin.m | 17 ++++++++----- plugin/package.json | 16 ++++++------ 9 files changed, 45 insertions(+), 33 deletions(-) diff --git a/example/RNExampleApp/android/app/build.gradle b/example/RNExampleApp/android/app/build.gradle index 87bd911..a2da7f7 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 "54.2.2" + versionName "54.4.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 89ae814..b523a45 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_54.2.1/Framework/AnylineResources.bundle", + "${PODS_ROOT}/Anyline/AnylineSDK_iOS_54.4.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 = 54.2.1; + MARKETING_VERSION = 54.4.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 = 54.2.1; + MARKETING_VERSION = 54.4.0; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", diff --git a/example/RNExampleApp/package.json b/example/RNExampleApp/package.json index 8d8de4c..7e2167e 100644 --- a/example/RNExampleApp/package.json +++ b/example/RNExampleApp/package.json @@ -1,6 +1,6 @@ { "name": "react-native-example-app", - "version": "54.2.2", + "version": "54.4.0", "private": true, "scripts": { "initProject": "yarn add expo && yarn add ../../plugin", diff --git a/example/RNExampleApp/src/index.js b/example/RNExampleApp/src/index.js index af28fd8..849cad1 100755 --- a/example/RNExampleApp/src/index.js +++ b/example/RNExampleApp/src/index.js @@ -241,6 +241,12 @@ class Anyline extends Component { } this.setState({ titles }); try { + const isInitialized = await AnylineOCR.isInitialized(); + console.log(`AnylineOCR.initialized: ` + isInitialized); + if (!isInitialized) { + await AnylineOCR.setupAnylineSDK(demoAppLicenseKey); + } + console.log(`AnylineOCR.setupPromise`); const result = await AnylineOCR.setupPromise( JSON.stringify(config), diff --git a/plugin/android/build.gradle b/plugin/android/build.gradle index 804a618..ecf22ee 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:54.2.0' + implementation 'io.anyline:anylinesdk:54.4.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 da96e2d..18de7d4 100755 --- a/plugin/android/src/main/java/com/anyline/reactnative/AnylineSDKPlugin.java +++ b/plugin/android/src/main/java/com/anyline/reactnative/AnylineSDKPlugin.java @@ -40,7 +40,6 @@ 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"; @@ -100,6 +99,11 @@ public void licenseKeyExpiryDate(final Promise promise) { } } + @ReactMethod + public void isInitialized(final Promise promise) { + promise.resolve(AnylineSdk.isInitialized()); + } + @ReactMethod @Deprecated public void setupScanViewWithConfigJson(String config, String scanMode, Callback onResultReact, Callback onErrorReact) { @@ -315,19 +319,17 @@ private void scan() throws LicenseException, JSONException { Intent intent = new Intent(getCurrentActivity(), ScanActivity.class); - configObject = new JSONObject(this.config); - - if (this.license == null || this.license.isEmpty()) { - if (configObject.has("license")) { - //if there is a license on JSON config then this license will be - //used to init or re-init the SDK - AnylineSdk.init(configObject.getString("license"), reactContext, "", CacheConfig.Preset.Default.INSTANCE, wrapperConfig); - license = configObject.get("license").toString(); - } else { - throw new JSONException("No License in config. Please check your configuration."); + if (!AnylineSdk.isInitialized()) { + if (this.license != null) { + AnylineSdk.init(this.license, reactContext, "", CacheConfig.Preset.Default.INSTANCE, wrapperConfig); + } + else { + throw new JSONException("SDK is not initialized. Please initialize SDK before scanning."); } } + configObject = new JSONObject(this.config); + JSONObject optionsJSONObject = configObject.optJSONObject("options"); if (optionsJSONObject != null) { @@ -337,7 +339,6 @@ private void scan() throws LicenseException, JSONException { ); } - intent.putExtra(EXTRA_LICENSE_KEY, license); intent.putExtra(EXTRA_CONFIG_JSON, configObject.toString()); intent.putExtra(EXTRA_SCANVIEW_INITIALIZATION_PARAMETERS, scanViewInitializationParameters); diff --git a/plugin/ios/AnylineReact.podspec b/plugin/ios/AnylineReact.podspec index 2099ff7..bfd9447 100644 --- a/plugin/ios/AnylineReact.podspec +++ b/plugin/ios/AnylineReact.podspec @@ -18,7 +18,7 @@ Pod::Spec.new do |s| s.source = { :git => "https://github.com/Anyline/anyline-ocr-react-native-module.git", :tag => "#{s.version}" } s.source_files = "*.{h,m}" - s.dependency "Anyline", "54.2.1" + s.dependency "Anyline", "54.4.0" s.dependency "React" end diff --git a/plugin/ios/AnylineSDKPlugin.m b/plugin/ios/AnylineSDKPlugin.m index 98ee6a8..13574aa 100644 --- a/plugin/ios/AnylineSDKPlugin.m +++ b/plugin/ios/AnylineSDKPlugin.m @@ -126,6 +126,11 @@ - (UIView *)view { resolve([AnylineSDK licenseExpirationDate]); } +RCT_EXPORT_METHOD(isInitialized:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { + BOOL isInitialized = [AnylineSDK isInitialized]; + resolve(@(isInitialized)); +} + RCT_EXPORT_METHOD(exportCachedEvents:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { _resolveBlock = resolve; _rejectBlock = reject; @@ -148,7 +153,7 @@ - (void)initView:(NSString *)scanMode initializationParamsStr:(NSString * _Nulla if (!data) { [NSException raise:@"Config could not be loaded from disk" format:@"Config could not be loaded from disk"]; } - + NSError *error = nil; id dictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; @@ -172,7 +177,7 @@ - (void)initView:(NSString *)scanMode initializationParamsStr:(NSString * _Nulla dispatch_async(dispatch_get_main_queue(), ^{ [[UIApplication sharedApplication] keyWindow].rootViewController.modalPresentationStyle = UIModalPresentationFullScreen; - + if ([[scanMode uppercaseString] isEqualToString:[@"scan" uppercaseString]]) { ALPluginScanViewController *pluginScanViewController = [[ALPluginScanViewController alloc] initWithLicensekey:self.appKey @@ -182,7 +187,7 @@ - (void)initView:(NSString *)scanMode initializationParamsStr:(NSString * _Nulla finished:^(NSDictionary * _Nullable callbackObj, NSError * _Nullable error) { [self returnCallback:callbackObj andError:error]; }]; - + if (pluginScanViewController != nil){ [pluginScanViewController setModalPresentationStyle: UIModalPresentationFullScreen]; [[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:pluginScanViewController animated:YES completion:nil]; @@ -196,7 +201,7 @@ - (void)initView:(NSString *)scanMode initializationParamsStr:(NSString * _Nulla finished:^(NSDictionary * _Nullable callbackObj, NSError * _Nullable error) { [self returnCallback:callbackObj andError:error]; }]; - + if (pluginScanViewController != nil){ [pluginScanViewController setModalPresentationStyle: UIModalPresentationFullScreen]; [[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:pluginScanViewController animated:YES completion:nil]; @@ -210,12 +215,12 @@ - (void)initView:(NSString *)scanMode initializationParamsStr:(NSString * _Nulla - (void)pluginScanViewController:(nonnull ALPluginScanViewController *)pluginScanViewController didScan:(nonnull id)scanResult continueScanning:(BOOL)continueScanning { NSString *resultJson = @""; - + NSError *error; NSData *jsonData = [NSJSONSerialization dataWithJSONObject: scanResult options:0 error:&error]; - + if (! jsonData) { NSLog(@"bv_jsonStringWithPrettyPrint: error: %@", error.localizedDescription); } else { diff --git a/plugin/package.json b/plugin/package.json index 0fdf6c7..ca40c1b 100644 --- a/plugin/package.json +++ b/plugin/package.json @@ -1,6 +1,6 @@ { - "_from": "anyline-ocr-react-native-module@^54.2.2", - "_id": "anyline-ocr-react-native-module@^54.2.2", + "_from": "anyline-ocr-react-native-module@^54.4.0", + "_id": "anyline-ocr-react-native-module@^54.4.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@^54.2.2", + "raw": "anyline-ocr-react-native-module@^54.4.0", "name": "anyline-ocr-react-native-module", "escapedName": "anyline-ocr-react-native-module", - "rawSpec": "^54.2.2", + "rawSpec": "^54.4.0", "saveSpec": null, - "fetchSpec": "^54.2.2" + "fetchSpec": "^54.4.0" }, "_requiredBy": [ "/" ], - "_resolved": "https://registry.npmjs.org/anyline-ocr-react-native-module/-/anyline-ocr-react-native-module-54.2.2.tgz", + "_resolved": "https://registry.npmjs.org/anyline-ocr-react-native-module/-/anyline-ocr-react-native-module-54.4.0.tgz", "_shasum": "bacbcd260cc662244f59393ed81a6edba009b52c", - "_spec": "anyline-ocr-react-native-module@^54.2.2", + "_spec": "anyline-ocr-react-native-module@^54.4.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": "54.2.2" + "version": "54.4.0" }