I am writing an iOS 8 application where a user can take a picture from a camera. I check the authorization status with this code (it is very simple, I am sure that everyone does this):
func showCameraImagePicker() { let authorizationStatus = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo) switch authorizationStatus { case .Authorized: // ... case .Denied: // ... case .Restricted: // ... case .NotDetermined: // ... } }
When I launch the application, it works well with any authorization status on first launch. However, if I go to the Settings application and change the authorization status, and then return to the application , the same code will be executed as if the authorization status had not been changed .
For example, if I first allowed access to the Camera, go to "Settings" and disable the camera for my application, and then return to the application, the code for .Authorized is still executed - it displays the UIImagePickerController but now with a black screen. When I exit the application and run it again, the code runs under .Denied .
How to make my code listen for changes in permissions in the Camera?
UPDATE
This is really strange - I also have this problem where the UIImagePickerController displays the camera shooter very slowly, and this only happens when debugging from Xcode . I started the application again without connecting it to the Xcode debugger and without changing the camera resolution on the settings screen, although it seems that it restarted my application (the application starts from the first screen, not where I left off before changing the permissions in the settings) . This is normal? How can I be sure that this error will not happen in the release build?
source share