Respect user privacy by seeking permission to capture and store photos, audio, and video.
Framework
- Bundle Resources
Overview
In iOS, the user must explicitly grant permission for each app to access cameras and microphones. Before your app can use the capture system for the first time, iOS shows an alert asking the user to grant your app access to the camera, as shown below. iOS remembers the user’s response to this alert, so subsequent uses of the capture system don’t cause it to appear again. The user can change permission settings for your app in Settings > Privacy.

To make sure your app has permission before capturing media, follow the steps below.
Configure Your App's Info.plist File
iOS requires that your app provide static messages to display to the user when the system asks for camera or microphone permission:
If your app uses device cameras, include the NSCameraUsageDescription key in your app’s Info.plist file.
If your app uses device microphones, include the NSMicrophoneUsageDescription key in your app’s Info.plist file.
For each key, provide a message that explains to the user why your app needs to capture media, so that the user can feel confident granting permission to your app.
Important
If the appropriate key is not present in your app’s Info
file when your app requests authorization or attempts to use a capture device, the system terminates your app.
Verify and Request Authorization for Capture
Always test the AVCapture
authorization
method before setting up a capture session. If the user has not yet granted or denied capture permission, the authorization status is AVAuthorization
. In this case, use the request
method to tell iOS to prompt the user:
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
}
The request
method is asynchronous: Your app continues running while iOS shows the permission alert. When the user responds, the system calls your completion handler. If the completion handler’s success parameter is true, you can proceed to set up and start a capture session.
Note
Call request
before starting capture, but only at a time that’s appropriate for your app. For example, if photo or video recording isn’t the main focus of your app, check for camera permission only when the user invokes your app’s camera-related features.
Request Authorization Before Saving Captured Media
After capturing photos or video, you may want to save them into the user’s Photos library. Accessing the Photos library also requires user permission (separate from camera and microphone permission). How and when you request permission depends on which features you use for saving media:
For most photo and video capture workflows (including Live Photos and RAW format capture), use the
PHPhoto
andLibrary PHAsset
classes. These classes require read/write access to the Photos library, so you must use the use the NSPhotoLibraryUsageDescription key in your Info.plist to provide a message to the user when asking for access. For details, see Saving Captured Photos.Creation Request If your app needs only to save movie files to the Photos library, the
UISave
function provides a simpler alternative toVideo At Path To Saved Photos Album PHPhoto
. This function requires only write access to the library, so use the NSPhotoLibraryAddUsageDescription key in your Info.plist to provide a message to the user when asking for permission to save to the Photos library.Library
Note
The UIImage
function is not recommended for use with photos captured with AVCapture
, because the UIImage
class does not support the features and metadata included in photo output.