mirror of
https://github.com/simplezhli/flutter_barcode_reader.git
synced 2024-11-23 04:39:20 +08:00
replaced iOs popup by throwing a flutter error
This commit is contained in:
parent
afb0ae21c0
commit
2156fe33fe
@ -27,7 +27,11 @@
|
||||
}
|
||||
|
||||
- (void)barcodeScannerViewController:(BarcodeScannerViewController *)controller didScanBarcodeWithResult:(NSString *)result {
|
||||
if (self.result) {
|
||||
if (self.result && [result isEqualToString: @"PERMISSION_NOT_GRANTED"]){
|
||||
self.result([FlutterError errorWithCode:@"PERMISSION_NOT_GRANTED"
|
||||
message:nil
|
||||
details:nil]);
|
||||
} else if (self.result) {
|
||||
self.result(result);
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,8 @@
|
||||
if (success) {
|
||||
[self startScan];
|
||||
} else {
|
||||
[self showNoCameraAccessAlert];
|
||||
[self.delegate barcodeScannerViewController:self didScanBarcodeWithResult:@"PERMISSION_NOT_GRANTED"];
|
||||
[self dismissViewControllerAnimated:NO completion:nil];
|
||||
}
|
||||
}];
|
||||
}
|
||||
@ -81,16 +82,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showNoCameraAccessAlert {
|
||||
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Camera access denied"
|
||||
message:@"Camera access has been disabled for this application. To turn camera access back on, please go to the iOS settings application."
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
[alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}]];
|
||||
[self presentViewController:alertController animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)toggle {
|
||||
[self toggleFlash:!self.isFlashOn];
|
||||
[self updateFlashButton];
|
||||
|
Loading…
Reference in New Issue
Block a user