Camera access authorized
ILCE-7RM4A
ICCameraDeviceCanTakePicture Optional("ICCameraDeviceCanAcceptPTPCommands")
requestOpenSession ()
didOpenSessionWithError nil
deviceDidBecomeReady Optional(0)
["ICCameraDeviceCanAcceptPTPCommands"]
func checkCameraAuthorization() {
let cameraAuthStatus = AVCaptureDevice.authorizationStatus(for: .video)
switch cameraAuthStatus {
case .authorized:
print("Camera access authorized")
case .notDetermined:
AVCaptureDevice.requestAccess(for: .video) { granted in
if granted {
print("Camera access granted")
} else {
print("Camera access denied")
}
}
case .denied, .restricted:
print("Camera access previously denied or restricted")
@unknown default:
fatalError("Unknown camera authorization status")
}
}
override init() {
self.deviceBrowser = ICDeviceBrowser();
super.init()
checkCameraAuthorization();
self.deviceBrowser.delegate = self;
// self.deviceBrowser.browsedDeviceTypeMask = .camera
self.deviceBrowser.start();
}