Попытка записать это:
if usergavepermissiontousercamera
opencamera
else
showmycustompermissionview
Не удалось найти текущий способ сделать эту простую задачу.
Примечание: Должен также работать iOS7, даже если он требует другого метода
Можно импортировать платформу AVFoundation и использовать authorizationStatus (для:) метод, показанный ниже и дескриптор соответствующие случаи.
switch AVCaptureDevice.authorizationStatus(for: .video) {
case .authorized: // The user has previously granted access to the camera.
self.setupCaptureSession()
case .notDetermined: // The user has not yet been asked for camera access.
AVCaptureDevice.requestAccess(for: .video) { granted in
if granted {
self.setupCaptureSession()
}
}
case .denied: // The user has previously denied access.
return
case .restricted: // The user can't grant access due to restrictions.
return
}