         
         guard let videoCaptureDevice = AVCaptureDevice.default(for: .video) else {
             // TODO: Handle the case without permission "Permission"
+            failed(QRReaderError.NO_PERMISSION)
             return
         }
         


import UIKit
import AVKit

class QRReader: CDVPlugin, AVCaptureMetadataOutputObjectsDelegate {
    

            return
        }
        
        guard captureSession.canAddInput(videoInput) else {
            failed(QRReaderError.SCANNING_UNSUPPORTED)
            return
        }
        captureSession.addInput(videoInput)

        let metadataOutput = AVCaptureMetadataOutput()
        
        guard captureSession.canAddOutput(metadataOutput) else {
            failed(QRReaderError.SCANNING_UNSUPPORTED)
            return
        }
        captureSession.addOutput(metadataOutput)

        metadataOutput.setMetadataObjectsDelegate(self, queue: DispatchQueue.main)
        metadataOutput.metadataObjectTypes = [.qr]
        
        previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
        previewLayer.frame = self.layer.bounds
        previewLayer.videoGravity = .resizeAspectFill

        self.layer.addSublayer(previewLayer)
        
        captureSession.startRunning()
