     }
     
     open func setupSession() {
+        #if swift(>=4.0)
         self.captureSession.sessionPreset = .photo
+        #else
+        self.captureSession.sessionPreset = AVCaptureSessionPresetPhoto
+        #endif
         
         self.setupCurrentDevice()
         

        }
        
        if #available(iOS 10.0, *) {
            if let photoCapture = self.captureOutput as? AVCapturePhotoOutput, let connection = photoCapture.connection(with: .video) {
                connection.videoOrientation = self.currentOrientation.toAVCaptureVideoOrientation()
                connection.videoScaleAndCropFactor = self.zoomScale
                

    
    open class func checkCameraPermission(_ handler: @escaping (_ granted: Bool) -> Void) {
        func hasCameraPermission() -> Bool {
            #if swift(>=4.0)
            return AVCaptureDevice.authorizationStatus(for: .video) == .authorized
            #else
            return AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) == .authorized
            #endif
        }
        
        func needsToRequestCameraPermission() -> Bool {
            #if swift(>=4.0)
            return AVCaptureDevice.authorizationStatus(for: .video) == .notDetermined
            #else
            return AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) == .notDetermined
            #endif
        }
        
        #if swift(>=4.0)
        hasCameraPermission() ? handler(true) : (needsToRequestCameraPermission() ?
            AVCaptureDevice.requestAccess(for: .video, completionHandler: { granted in
                DispatchQueue.main.async(execute: { () -> Void in
                    hasCameraPermission() ? handler(true) : handler(false)
                })
            }) : handler(false))
        #else
        hasCameraPermission() ? handler(true) : (needsToRequestCameraPermission() ?
            AVCaptureDevice.requestAccess(forMediaType: AVMediaTypeVideo, completionHandler: { granted in
                DispatchQueue.main.async(execute: { () -> Void in
                    hasCameraPermission() ? handler(true) : handler(false)
                })
            }) : handler(false))
        #endif
    }
    
    open var didCancel: (() -> Void)?
