Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit d89f7d4

Browse files
Fatal error using MLKitBarcodeScanner #1153
1 parent 5823548 commit d89f7d4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: src/mlkit/mlkit-cameraview.ios.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,14 @@ export abstract class MLKitCameraView extends MLKitCameraViewBase {
5757
this.captureSession = AVCaptureSession.new();
5858
this.captureSession.sessionPreset = AVCaptureSessionPreset1280x720;
5959

60-
const captureDeviceInput = AVCaptureDeviceInput.deviceInputWithDeviceError(this.captureDevice);
61-
this.captureSession.addInput(captureDeviceInput);
60+
try {
61+
const captureDeviceInput = AVCaptureDeviceInput.deviceInputWithDeviceError(this.captureDevice);
62+
this.captureSession.addInput(captureDeviceInput);
63+
} catch (e) {
64+
// likely here, because the camera permission was previously denied (catching, otherwise the app crashes)
65+
console.log("Error while trying to use the camera: " + e);
66+
return;
67+
}
6268

6369
this.previewLayer = AVCaptureVideoPreviewLayer.layerWithSession(this.captureSession);
6470
this.previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;

0 commit comments

Comments
 (0)