1

Since iOS 14 there is a new API for photo selection called PHPhotoPicker. Alongside that, newly feature has been added and it allows users to give permission for only selected photos to be accessed by the iOS app.

Considering that, I want to be able to show only photos which user granted access to when opening instance of PHPhotoPicker inside my app.

Code I have so far:

        switch PHPhotoLibrary.authorizationStatus(for: .readWrite) {
        case .authorized:
            //present PHPhotoPicker with content of entire photo library
                var config = PHPickerConfiguration()
                config.filter = .images
                let vc = PHPickerViewController(configuration: config)
                vc.delegate = self
                viewController.present(vc, animated: true, completion: nil)
        case .limited:
            //present PHPhotoPicker with only photos user granted access to
        }
    

As far as i've done my research it is possible to present PHPPicker which lets users choose photos to which they grant access (see code bellow), but not possible to actually show any kind of image picker which shows only photos with granted access.

PHPhotoLibrary.shared().presentLimitedLibraryPicker(from: self)

Apple documentation isn't really lengthy which surprises me because it makes no sense to be able to present PHPhotoPicker which allows you to give access to certain photos, but then not have a way to present those photos in an image picker.

EDIT:

WhatsApp app example:
• In settings user can select photos which he is fine for the app to have access to: First picture

•Then when he opens the Whatsapp app and tries to send a photo he gets Photo picker noted with number 2 on the picture below:

Second picture

If he didn't choose "Selected photos" but instead chose "All photos" then he would have photo picker of an entire library shown on second picture and marked with "1. Access to all photos".

So my question is: How to present image picker with only selected photos(second picture number 2.) instead of image picker with entire photo library(second picture number 1.)

cXode
  • 29
  • 7
  • I don't know if I understood your question right, but I think the `PHPhotoLibraryPreventAutomaticLimitedAccessAlert` key is what you are looking for, added to info.plist. It will prevent that prompt from showing up, and instead will show current image selection. See this demo for example: https://swiftsenpai.com/development/photo-library-permission/ – timbre timbre Dec 07 '21 at 22:25
  • @KirilS. it seems you didn't quite understand the question i posted so I added an real life example. Feel free to check it out and let me know if you know the answer. – cXode Dec 08 '21 at 08:10

1 Answers1

0

этого нельзя сделать - https://developer.apple.com/forums/thread/658485

Even if your app is under Limited Photos Library mode, PHPicker will still show the entire photos library (all photos and videos can be selected by the user as well).

  • Please write **all of** your answer in English, as [Stack Overflow is an English site.](//meta.stackexchange.com/q/13676) – Adrian Mole Feb 12 '22 at 22:17