delba / Permission

A unified API to ask for permissions on iOS
MIT License
2.9k stars 320 forks source link

Wrong camera permission #125

Closed Album1993 closed 4 years ago

Album1993 commented 6 years ago

Hi the camera permission is out of date . the right one is blow

import AVFoundation

internal extension Permission {
    var statusCamera: PermissionStatus {
        let status = AVCaptureDevice.authorizationStatus(for: AVMediaType.video)

        switch status {
        case .authorized:          return .authorized
        case .restricted, .denied: return .denied
        case .notDetermined:       return .notDetermined
        }
    }

    func requestCamera(_ callback: @escaping Callback) {
        guard let _ = Bundle.main.object(forInfoDictionaryKey: .cameraUsageDescription) else {
            print("WARNING: \(String.cameraUsageDescription) not found in Info.plist")
            return
        }

        AVCaptureDevice.requestAccess(for: AVMediaType.video) { _ in
            callback(self.statusCamera)
        }
    }
}
delba commented 4 years ago

Hi @Album1993, could you please update to the latest version of Permission ? Also I'm not sure what you mean by "the right one is blow" ?