replaced iOs popup by throwing a flutter error

This commit is contained in:
Benjamin Sauer 2018-01-08 14:41:49 +01:00
parent afb0ae21c0
commit 2156fe33fe
2 changed files with 8 additions and 13 deletions

View File

@ -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);
}
}

View File

@ -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];
@ -132,4 +123,4 @@
}
@end
@end