Navaron Bracke

check if torch mode is supported on iOS

... ... @@ -286,9 +286,15 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
device = nil
}
/// Toggle the flashlight between on and off.
/// Set the torch mode.
///
/// This method should be called on the main DispatchQueue.
func toggleTorch(_ torch: AVCaptureDevice.TorchMode) throws {
if (device == nil || !device.hasTorch || !device.isTorchAvailable) {
guard let device = self.device else {
return
}
if (!device.hasTorch || !device.isTorchAvailable || !device.isTorchModeSupported(torch)) {
return
}
... ...