Requests the user’s permission, if needed, to access the photo library.
- iOS 8+
- macOS 10.13+
- Mac Catalyst 13.0+Beta
- tvOS 10+
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
Accessing the photo library always requires explicit permission from the user. The first time your app uses
PHCollection 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
PHFetch 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.