iOS 10 - Changes in asking permissions of Camera, microphone and Photo Library causing application to crash
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
In the transition to iOS 10, Apple introduced several significant changes to how applications handle permissions, particularly for accessing the camera, microphone, and photo library. These changes were designed to enhance user privacy and security but inadvertently caused many applications to crash, especially those that hadn't adhered to Apple's revised permission request protocols.
Understanding the Permission System in iOS 10
Before iOS 10, apps could somewhat ambiguously access certain device resources with fewer explicit permission requests. This limited transparency raised privacy concerns, and Apple aimed to address these by prompting users more visibly and clearly when apps attempted to access sensitive resources.
Key Changes
- Mandatory Permission Descriptions: In iOS 10, Apple required developers to provide purpose strings in their `Info.plist` files for permission requests. These strings explain to the user why the app needs access to resources like the camera, microphone, or photo library.
- Runtime Permission Dialogs: Permissions now prompt in context, ensuring that users are informed and in control of their data. This change means that application usage flow must now incorporate potential halts while users approve or deny access.
- Error Handling: Apps not configured to handle denied permissions gracefully could encounter unexpected behavior or crashes.
Technical Explanation
Implementing Permission Descriptions
`Info.plist` configuration became crucial for apps needing access to:
- Camera: NSCameraUsageDescription
- Microphone: NSMicrophoneUsageDescription
- Photo Library: NSPhotoLibraryUsageDescription
Without these keys, the app would crash upon attempting access, as iOS would forcibly terminate the app for trying to access a restricted resource without user consent.
Example Code
Here's a basic example illustrating how to request permission for camera access:
- User Education: Create clear, concise purpose strings that inform users and increase the likelihood of permission grants.
- Better UX for Permissions: Implement fallback logic and alerts, guiding users to settings with visual and simple instructions.
- Continuous Monitoring: As iOS updates continue, monitor Apple's guidelines for any changes in permission handling.

