 
 import UIKit
 import AVKit
+
+enum QRReaderError {
+  case NO_PERMISSION
+  case SCANNING_UNSUPPORTED
+}
 
 class QRReader: CDVPlugin, AVCaptureMetadataOutputObjectsDelegate {
     

        captureSession.stopRunning()
    }
    
    func failed() {
        print("Scanning unsupported")
        captureSession = nil
    }
    
    // override func viewWillAppear(_ animated: Bool) {
    //     super.viewWillAppear(animated)
    
    //     if (captureSession?.isRunning == false) {
    //         captureSession.startRunning()
    //     }
    // }
    
    // override func viewWillDisappear(_ animated: Bool) {
    //     super.viewWillDisappear(animated)
    
    //     if (captureSession?.isRunning == true) {
    //         captureSession.stopRunning()
    //     }
    // }
    
    func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection) {
        captureSession.stopRunning()

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