Search code examples
uiimagepickercontrollerios10privacy

Privacy violation for movies, but not for photos when using UIImagePickerController in iOS 10


I have an app that can take photos and movies using an UIImagePickerController.
I have set NSCameraUsageDescription in Info.plist (actually, localized in InfoPlist.strings).

When the app was launched and I tried to take a photo, I was asked for permission, which I granted. Now, I can take photos without problems.

However, when I try to take a movie, the app crashes always due to a privacy violation (see stack trace below). This crash happens sometimes before the camera interface is presented, and sometime afterwards (see screenshot below).

I don’t think it has anything to do with the way I present the camera interface, but here is the code anyway:

+ (void)takePhotoOrMovie:(CFStringRef)mediaType inViewController:(UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate> *)viewController 
{
    UIImagePickerController *takePhotoOrMovieController = [[UIImagePickerController alloc] init];
    takePhotoOrMovieController.sourceType = UIImagePickerControllerSourceTypeCamera;
    NSString *mediaTypePhotoOrMovie = (__bridge NSString *)mediaType;
    takePhotoOrMovieController.mediaTypes = @[mediaTypePhotoOrMovie];
    takePhotoOrMovieController.allowsEditing = YES; // Enables the controls for editing
    takePhotoOrMovieController.delegate = viewController;
    [viewController presentViewController:takePhotoOrMovieController animated:YES completion:nil];
}

The parameter mediaType is kUTTypeImage for photo and kUTTypeMovie for movie.

Any idea what is wrong and how to correct it?

enter image description here enter image description here


Solution

  • You need to provide a NSMicrophoneUsageDescription key also.