3

When my app needs to access the user's photo library for the first time, they are shown these three options:

enter image description here

How can I check if the user has chosen the "Select Photos..." option?

PHPhotoLibrary.authorizationStatus() will have the status PHAuthorizationStatus.authorized if you select both "Select Photos..." or "Allow Access to All Photos" and I can't find a way of knowing it is the "Select Photos..." option.

1 Answers1

3

There is a new API for reading the auth status in iOS 14. Only the new API supports PHAuthorizationStatus.limited status.

PHPhotoLibrary.requestAuthorization(for: .readWrite) { status in
    switch status {
    case .limited:
        // handle the case
    case .authorized:
        // ...
    case .denied:
        // ...
    case .restricted:
        // ...
    case .notDetermined:
        // ...
    }
}

With presentLimitedLibraryPicker(from:) you can manually present the limited library picker.

The old requestAuthorization(_:) is now deprecated.

Witek Bobrowski
  • 3,749
  • 1
  • 20
  • 34
  • 2
    Perfect - much appreciated :). –  Dec 17 '20 at 19:55
  • If the user closes the app and reopens the app, the status becomes "authorized". Any way to get it to return "limited" again? Maybe this is an apple bug. I'm on iOS 16. – Peter Tao Oct 01 '22 at 21:35