Skip to content

Commit

Permalink
Release 53.0.0 (#177)
Browse files Browse the repository at this point in the history
* Release 53.0.0
  • Loading branch information
vimalvenugopalananyline authored Aug 1, 2024
1 parent 8c9ccc1 commit a2265f9
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 136 deletions.
2 changes: 1 addition & 1 deletion example/RNExampleApp/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 5
versionName "52.0.1"
versionName "53.0.0"
multiDexEnabled true

buildConfigField("boolean", "REACT_NATIVE_UNSTABLE_USE_RUNTIME_SCHEDULER_ALWAYS", (findProperty("reactNative.unstable_useRuntimeSchedulerAlways") ?: true).toString())
Expand Down
4 changes: 2 additions & 2 deletions example/RNExampleApp/config/OdometerConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export default {
}
},
"scanFeedbackConfig" : {
"style" : "CONTOUR_RECT",
"style" : "contour_rect",
"strokeColor" : "0099FF",
"fillColor" : "220099FF",
"blinkOnResult": true,
"blinkAnimationOnResult": true,
"beepOnResult": true,
"vibrateOnResult": true
}
Expand Down
4 changes: 2 additions & 2 deletions example/RNExampleApp/config/SerialScanningConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ export default {
"feedbackStrokeColor": "0099FF"
},
"scanFeedbackConfig": {
"style": "CONTOUR_RECT",
"visualFeedbackRedrawTimeout": 100,
"style": "contour_rect",
"redrawTimeout": 100,
"strokeColor": "0099FF",
"fillColor": "220099FF",
"beepOnResult": true,
Expand Down
1 change: 0 additions & 1 deletion example/RNExampleApp/config/TINDOTConfig.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export default {
license: '', //INSERT YOUR LICENSE KEY HERE
"options": {
"doneButtonConfig": {
"offset.y": -88
Expand Down
4 changes: 2 additions & 2 deletions example/RNExampleApp/config/UniversalIdConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ export default {
"feedbackStrokeColor": "0099FF"
},
"scanFeedbackConfig": {
"style": "CONTOUR_RECT",
"visualFeedbackRedrawTimeout": 100,
"style": "contour_rect",
"redrawTimeout": 100,
"strokeColor": "0099FF",
"fillColor": "220099FF",
"beepOnResult": true,
Expand Down
94 changes: 38 additions & 56 deletions example/RNExampleApp/ios/RNExampleApp.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/RNExampleApp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-example-app",
"version": "52.0.1",
"version": "53.0.0",
"private": true,
"scripts": {
"initProject": "yarn add expo && yarn add ../../plugin",
Expand Down
2 changes: 1 addition & 1 deletion plugin/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ repositories {

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'io.anyline:anylinesdk:52.0.1'
implementation 'io.anyline:anylinesdk:53.0.0'
implementation "com.facebook.react:react-native:+"
implementation("com.google.android.material:material:1.9.0")
implementation 'androidx.multidex:multidex:2.0.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
};
} catch (JSONException e) {
finishWithError("Error parsing view config: " + e.getMessage());
} catch (Exception e) {
finishWithError(getString(getResources().getIdentifier("error_invalid_json_data", "string", getPackageName()))
+ "\n" + e.getLocalizedMessage());
}
} else {
finishWithError("View config not found");
Expand Down Expand Up @@ -370,6 +373,7 @@ private void finishWithError(String errorMessage) {
Intent intent = new Intent();
intent.putExtra(EXTRA_ERROR_MESSAGE, errorMessage);
setResult(RESULT_ERROR, intent);
ResultReporter.onError(errorMessage);
finish();
}

Expand All @@ -382,13 +386,17 @@ protected void onSaveInstanceState(Bundle outState) {
@Override
protected void onResume() {
super.onResume();
scanView.start();
if (scanView.isInitialized()) {
scanView.start();
}
}

@Override
protected void onPause() {
scanView.stop();
scanView.getCameraView().releaseCameraInBackground();
if (scanView.isInitialized()) {
scanView.stop();
scanView.getCameraView().releaseCameraInBackground();
}
super.onPause();
}

Expand Down
16 changes: 7 additions & 9 deletions plugin/ios/ALNFCScanViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ - (void)viewDidLoad {
return;
}

self.mrzScanViewPlugin = (ALScanViewPlugin *)self.scanView.scanViewPlugin;
self.mrzScanViewPlugin = (ALScanViewPlugin *)self.scanView.viewPlugin;

self.scanView.supportedNativeBarcodeFormats = self.uiConfig.nativeBarcodeFormats;
self.scanView.delegate = self;
Expand Down Expand Up @@ -155,7 +155,7 @@ - (void)stopMRZScanning {

- (void)configureMRZPlugin {

ALScanViewPlugin *scanViewPlugin = (ALScanViewPlugin *)self.scanView.scanViewPlugin;
ALScanViewPlugin *scanViewPlugin = (ALScanViewPlugin *)self.scanView.viewPlugin;
if (![scanViewPlugin isKindOfClass:ALScanViewPlugin.class]) {
return;
}
Expand Down Expand Up @@ -183,14 +183,12 @@ - (void)configureMRZPlugin {
mrzConfig.mrzMinFieldConfidences.dateOfExpiry = @(90);

NSError *error;
ALScanViewPluginConfig *scanViewPluginConfig = [ALScanViewPluginConfig withPluginConfig:pluginConfig
cutoutConfig:cutoutConfig
scanFeedbackConfig:scanFeedbackConfig];
ALScanViewPlugin *updatedScanViewPlugin = [[ALScanViewPlugin alloc] initWithConfig:scanViewPluginConfig error:&error];
[self.scanView setScanViewPlugin:updatedScanViewPlugin error:&error];

ALViewPluginConfig *scanViewPluginConfig = scanViewPlugin.scanViewPluginConfig;
[self.scanView setViewPluginConfig:scanViewPluginConfig error:&error];

// the delegate binding was lost when you recreated the ScanPlugin it so you have to bring it back here
scanViewPlugin = (ALScanViewPlugin *)self.scanView.scanViewPlugin;
scanViewPlugin = (ALScanViewPlugin *)self.scanView.viewPlugin;
scanViewPlugin.scanPlugin.delegate = self;
}

Expand Down Expand Up @@ -243,7 +241,7 @@ - (void)handleResult:(id _Nullable)resultObj {
resultDictionary[@"nativeBarcodesDetected"] = self.detectedBarcodes;
}

NSObject<ALScanViewPluginBase> *scanViewPluginBase = self.scanView.scanViewPlugin;
NSObject<ALViewPluginBase> *scanViewPluginBase = self.scanView.viewPlugin;
if ([scanViewPluginBase isKindOfClass:ALScanViewPlugin.class]) {
ALScanViewPlugin *scanViewPlugin = (ALScanViewPlugin *)scanViewPluginBase;
BOOL cancelOnResult = scanViewPlugin.scanPlugin.pluginConfig.cancelOnResult;
Expand Down
2 changes: 1 addition & 1 deletion plugin/ios/ALPluginHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ NS_ASSUME_NONNULL_BEGIN

@class ALPluginConfig;

typedef void (^ALPluginCallback)(id _Nullable callbackObj, NSString * _Nullable errorString);
typedef void (^ALPluginCallback)(NSDictionary * _Nullable callbackObj, NSError * _Nullable error);


@interface ALPluginHelper : NSObject
Expand Down
7 changes: 4 additions & 3 deletions plugin/ios/ALPluginHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ + (void)startScan:(NSDictionary *)config finished:(ALPluginCallback)callback {
if (@available(iOS 13.0, *)) {

if (![ALNFCDetector readingAvailable]) {
callback(nil, @"NFC passport reading is not supported on this device or app.");
callback(nil, [NSError errorWithDomain:@"ALReactDomain" code:100 userInfo:@{@"Error reason": @"NFC passport reading is not supported on this device or app."}]);

return;
}

Expand All @@ -42,7 +43,7 @@ + (void)startScan:(NSDictionary *)config finished:(ALPluginCallback)callback {
completion:nil];
}
} else {
callback(nil, @"NFC passport reading is only supported on iOS 13 and later.");
callback(nil,[NSError errorWithDomain:@"ALReactDomain" code:100 userInfo:@{@"Error reason": @"NFC passport reading is only supported on iOS 13 and later."}]);
return;
}
} else {
Expand Down Expand Up @@ -288,7 +289,7 @@ + (BOOL)showErrorAlertIfNeeded:(NSError *)error pluginCallback:(ALPluginCallback

[[UIApplication sharedApplication].keyWindow.rootViewController
dismissViewControllerAnimated:YES completion:^{
callback(nil, @"Canceled");
callback(nil, [NSError errorWithDomain:@"" code:-1 userInfo:@{@"Error reason": @"Canceled"}]);
}];
}];

Expand Down
61 changes: 40 additions & 21 deletions plugin/ios/ALPluginScanViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ @interface ALPluginScanViewController () <ALScanPluginDelegate, ALViewPluginComp
/// Applicable to non-composites (otherwise null)
@property (nonatomic, readonly, nullable) ALPluginConfig *pluginConfig;

@property (nonatomic, strong) NSError *scanViewError;

@end


Expand Down Expand Up @@ -82,8 +84,9 @@ - (void)viewDidLoad {
error:&error];

if ([self showErrorAlertIfNeeded:error]) {
return;
}
self.scanViewError = error;
return;
}

[self.view addSubview:self.scanView];

Expand Down Expand Up @@ -118,8 +121,15 @@ - (void)viewDidAppear:(BOOL)animated {
[UIApplication sharedApplication].idleTimerDisabled = YES;

NSError *error;
[self.scanView.scanViewPlugin startWithError:&error];
[self showErrorAlertIfNeeded:error];
if(!self.scanViewError){
[self.scanView.viewPlugin startWithError:&error];
[self showErrorAlertIfNeeded:error];
}
else{
[self dismissViewControllerAnimated:YES completion:^{
self.callback(nil, self.scanViewError);
}];
}
}

- (void)viewDidDisappear:(BOOL)animated {
Expand Down Expand Up @@ -200,7 +210,7 @@ - (void)handleResult:(id _Nullable)resultObj {
}

// dismiss the view controller, if cancelOnResult for the config is true
NSObject<ALScanViewPluginBase> *scanViewPluginBase = self.scanView.scanViewPlugin;
NSObject<ALViewPluginBase> *scanViewPluginBase = self.scanView.viewPlugin;
if ([scanViewPluginBase isKindOfClass:ALScanViewPlugin.class]) {
ALScanViewPlugin *scanViewPlugin = (ALScanViewPlugin *)scanViewPluginBase;
BOOL cancelOnResult = scanViewPlugin.scanPlugin.pluginConfig.cancelOnResult;
Expand Down Expand Up @@ -289,7 +299,7 @@ - (void)scanView:(ALScanView *)scanView didReceiveNativeBarcodeResult:(ALScanRes

- (ALPluginConfig * _Nullable)pluginConfig {
// applic. only to non-composites
NSObject<ALScanViewPluginBase> *scanVwPluginBase = self.scanView.scanViewPlugin;
NSObject<ALViewPluginBase> *scanVwPluginBase = self.scanView.viewPlugin;
if ([scanVwPluginBase isKindOfClass:ALScanViewPlugin.class]) {
return ((ALScanViewPlugin *)scanVwPluginBase).scanPlugin.pluginConfig;
}
Expand All @@ -299,11 +309,11 @@ - (ALPluginConfig * _Nullable)pluginConfig {
// MARK: - Selector Actions

- (void)doneButtonPressed:(id)sender {
[self.scanView.scanViewPlugin stop];
[self.scanView.viewPlugin stop];

__weak __block typeof(self) weakSelf = self;
[self dismissViewControllerAnimated:YES completion:^{
weakSelf.callback(nil, @"Canceled");
weakSelf.callback(nil, [NSError errorWithDomain:@"ALReactDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey: @"Canceled"}]);
}];
}

Expand Down Expand Up @@ -356,25 +366,23 @@ - (void)updateScanModeWithValue:(NSString *)modeString {

// assume that pluginConfig carries the updated scanMode or whatever value that you wish to refresh.
- (BOOL)updatePluginConfig:(ALPluginConfig *)pluginConfig error:(NSError * _Nullable * _Nullable)error {
ALScanViewPluginConfig *origSVPConfig = ((ALScanViewPlugin *)self.scanView.scanViewPlugin).scanViewPluginConfig;
ALScanViewPluginConfig *scanViewPluginConfig = [ALScanViewPluginConfig withPluginConfig:pluginConfig
cutoutConfig:origSVPConfig.cutoutConfig
scanFeedbackConfig:origSVPConfig.scanFeedbackConfig];
ALScanViewPlugin *newScanViewPlugin = [[ALScanViewPlugin alloc] initWithConfig:scanViewPluginConfig error:error];
if (!newScanViewPlugin) {
return NO;
}

newScanViewPlugin.scanPlugin.delegate = self;
ALViewPluginConfig *origSVPConfig = ((ALScanViewPlugin *)self.scanView.viewPlugin).scanViewPluginConfig;

BOOL success = [self.scanView setScanViewPlugin:newScanViewPlugin error:error];
origSVPConfig.pluginConfig = pluginConfig;
BOOL success = [self.scanView setViewPluginConfig:origSVPConfig error:error];
if (!success) {
if([self showErrorAlertIfNeeded:*error]){
[self dismissOnError:*error];
}
return NO;
}

success = [[self.scanView scanViewPlugin] startWithError:error];
success = [self.scanView.viewPlugin startWithError:error];
if (!success) {
// check error
if([self showErrorAlertIfNeeded:*error]){
[self dismissOnError:*error];
}
return NO;
}
return YES;
Expand Down Expand Up @@ -429,7 +437,18 @@ - (BOOL)segmentModesAreValid {
// MARK: - Miscellaneous

- (BOOL)showErrorAlertIfNeeded:(NSError *)error {
return [ALPluginHelper showErrorAlertIfNeeded:error pluginCallback:self.callback];
if (!error) {
return NO;
}

return YES;
}

-(void)dismissOnError:(NSError *)error{
[self dismissViewControllerAnimated:YES completion:^{
self.callback(nil, error);
}];
}


@end
2 changes: 1 addition & 1 deletion plugin/ios/AnylineReact.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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", "~> 52"
s.dependency "Anyline", "53.0.0"
s.dependency "React"

end
Loading

0 comments on commit a2265f9

Please sign in to comment.