Type Method


Requests the user’s permission, if needed, to access the photo library.


class func requestAuthorization(_ handler: @escaping (PHAuthorizationStatus) -> Void)



A block Photos calls upon determining your app’s authorization to access the photo library.

The block takes a single parameter:


The current authorization status. See PHAuthorizationStatus.


Accessing the photo library always requires explicit permission from the user. 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. Alternatively, you can call this method to prompt the user at a time of your choosing.

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, not 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 perform changes to the photo library will fail.

This method always returns immediately. If the user has previously granted or denied photo library access permission, it executes the handler block when called; otherwise, it displays an alert and executes the block only after the user has responded to the alert.

See Also

Verifying Authorization

class func authorizationStatus() -> PHAuthorizationStatus

Returns information about your app’s authorization to access the user’s photo library.

enum PHAuthorizationStatus

Information about your app’s authorization to access the user’s photo library, used by the authorizationStatus() and requestAuthorization(_:) methods.