@scr2em/capacitor-scanner 6.0.28 → 6.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -417,6 +417,24 @@ public class CapacitorScannerPlugin: CAPPlugin, CAPBridgedPlugin, AVCaptureMetad
|
|
|
417
417
|
let enableBarcodeHighlight = call.getBool("barcodeHighlight", false)
|
|
418
418
|
let enableObjectHighlight = call.getBool("objectHighlight", true)
|
|
419
419
|
|
|
420
|
+
// Ensure camera permission is granted before setting up the session
|
|
421
|
+
let status = AVCaptureDevice.authorizationStatus(for: .video)
|
|
422
|
+
if status == .denied || status == .restricted {
|
|
423
|
+
call.reject("Camera permission denied")
|
|
424
|
+
return
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
if status == .notDetermined {
|
|
428
|
+
AVCaptureDevice.requestAccess(for: .video) { granted in
|
|
429
|
+
if granted {
|
|
430
|
+
self.start(call)
|
|
431
|
+
} else {
|
|
432
|
+
call.reject("Camera permission denied")
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return
|
|
436
|
+
}
|
|
437
|
+
|
|
420
438
|
DispatchQueue.main.async {
|
|
421
439
|
// Stop any existing session first (must be on main thread for UI operations)
|
|
422
440
|
self.stopInternal()
|