diff --git a/ios/Classes/BarcodeScanPlugin.m b/ios/Classes/BarcodeScanPlugin.m index 97ff856..40ad5ac 100644 --- a/ios/Classes/BarcodeScanPlugin.m +++ b/ios/Classes/BarcodeScanPlugin.m @@ -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); } } diff --git a/ios/Classes/BarcodeScannerViewController.m b/ios/Classes/BarcodeScannerViewController.m index 6dbdc4e..114db43 100644 --- a/ios/Classes/BarcodeScannerViewController.m +++ b/ios/Classes/BarcodeScannerViewController.m @@ -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 \ No newline at end of file +@end