I'm writing an iOS 8 app where the user can take a photo from the Camera. I check for authorization status using this code (it's very straightforward, I'm pretty sure everybody does it this way):
func showCameraImagePicker() {
let authorizationStatus = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo)
switch authorizationStatus {
case .Authorized:
// ...
case .Denied:
// ...
case .Restricted:
// ...
case .NotDetermined:
// ...
}
}
When I run the app, it works well with whatever the authorization status was on first run. However, if I go to the Settings app and change the authorization status, then return to the app, the same code is executed as if the authorization status wasn't changed.
For example, if I have initially allowed Camera access, then go to Settings and disable the Camera for my app, then come back to the app, the code for .Authorized
is still executed--it displays a UIImagePickerController
but now with a black screen. When I terminate the app and run it again, code under .Denied
is run.
How do I make my code listen to changes to permissions in the Camera?
UPDATE
This is really strange--I also happen to have this problem where the UIImagePickerController
is very slow to display the Camera shooter, and it only happens when debugging from Xcode. I ran my app again without connecting it to Xcode's debugger and changing the Camera permissions in the Settings screen works, though it seems to restart my app (the app starts over from the first screen instead of where I left off before changing the permissions in Settings). Is this normal? How can I be sure that this error won't happen in a release build?