mirror of
https://github.com/simplezhli/flutter_barcode_reader.git
synced 2024-11-23 07:59:20 +08:00
BarcodeScanPlugin.m: extracted errorHandling into seperate method
This commit is contained in:
parent
616b286a5c
commit
1c34da8db9
@ -27,13 +27,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)barcodeScannerViewController:(BarcodeScannerViewController *)controller didScanBarcodeWithResult:(NSString *)result {
|
- (void)barcodeScannerViewController:(BarcodeScannerViewController *)controller didScanBarcodeWithResult:(NSString *)result {
|
||||||
if (self.result && [result isEqualToString: @"PERMISSION_NOT_GRANTED"]){
|
if (self.result) {
|
||||||
self.result([FlutterError errorWithCode:@"PERMISSION_NOT_GRANTED"
|
|
||||||
message:nil
|
|
||||||
details:nil]);
|
|
||||||
} else if (self.result) {
|
|
||||||
self.result(result);
|
self.result(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)barcodeScannerViewController:(BarcodeScannerViewController *)controller didScanBarcodeWithErrorCode:(NSString *)errorCode {
|
||||||
|
if (self.result){
|
||||||
|
self.result([FlutterError errorWithCode:errorCode
|
||||||
|
message:nil
|
||||||
|
details:nil]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
if (success) {
|
if (success) {
|
||||||
[self startScan];
|
[self startScan];
|
||||||
} else {
|
} else {
|
||||||
[self.delegate barcodeScannerViewController:self didScanBarcodeWithResult:@"PERMISSION_NOT_GRANTED"];
|
[self.delegate barcodeScannerViewController:self didScanBarcodeWithErrorCode:@"PERMISSION_NOT_GRANTED"];
|
||||||
[self dismissViewControllerAnimated:NO completion:nil];
|
[self dismissViewControllerAnimated:NO completion:nil];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
@ -9,5 +9,6 @@
|
|||||||
@protocol BarcodeScannerViewControllerDelegate <NSObject>
|
@protocol BarcodeScannerViewControllerDelegate <NSObject>
|
||||||
|
|
||||||
- (void)barcodeScannerViewController:(BarcodeScannerViewController *)controller didScanBarcodeWithResult:(NSString *)result;
|
- (void)barcodeScannerViewController:(BarcodeScannerViewController *)controller didScanBarcodeWithResult:(NSString *)result;
|
||||||
|
- (void)barcodeScannerViewController:(BarcodeScannerViewController *)controller didScanBarcodeWithErrorCode:(NSString *)errorCode;
|
||||||
|
|
||||||
@end
|
@end
|
Loading…
Reference in New Issue
Block a user