Requesting Authorization to Access Photos

Prepare your app to ask for permission when accessing the user's photo library.


The user must explicitly grant permission for your app to access Photos. Prepare your app for this requirement by providing justification strings. The justification string is a localizable message that you add to your app's Info.plist file to tell the user why your app needs access to the user's photo library. Then, when Photos prompts the user to grant permission for access, the alert displays the justification string you provided, in the language of the locale selected on the user's device.

The first time your app uses PHAsset, PHCollection, PHAssetCollection, or PHCollectionList methods to fetch content from the library, or uses one of the methods listed in Applying Changes to the Photo Library to request changes to library content, Photos automatically and asynchronously prompts the user to request authorization.

After the user grants permission, the system remembers the choice for future use in your app, but the user can change this choice at any time using the Settings app. If the user has denied your app photo library access, hasn't yet responded to the permission prompt, or cannot grant access due to restrictions, any attempts to fetch photo library content will return empty PHFetchResult objects, and any attempts to make changes to the photo library will fail. If this method returns PHAuthorizationStatus.notDetermined, you can call the requestAuthorization(_:) method to prompt the user for photo library access permission.

Update Your App's Info.plist File

To use classes that interact with the Photos library, such as PHAsset, PHPhotoLibrary, and PHImageManager, your app's Info.plist file must include user-facing text for the NSPhotoLibraryUsageDescription key, which the system displays when asking the user for access permission. Apps linked on or after iOS 10 will crash if this key is not present.

Figure 1

The value associated with the NSPhotoLibraryUsageDescription key is the string the user will see when prompted to grant access.

A screenshot of an Info.plist file in Xcode with NSPhotoLibraryUsageDescription filled in

Observe Changes Before Fetching

Use the register(_:) method to observe photo library changes before fetching content. After the user grants your app access to the photo library, Photos sends change messages for any empty fetch results you retrieved earlier, notifying you that library content for those fetches is now available.

See Also


property list key NSPhotoLibraryAddUsageDescription

A message that tells the user why the app is requesting write-only access to the user’s photo library.

Name: Privacy - Photo Library Additions Usage Description
property list key NSPhotoLibraryUsageDescription

A message that tells the user why the app is requesting access to the user’s photo library.

Name: Privacy - Photo Library Usage Description