PHAccessLevel .addOnly triggers .readWrite permissions still after use

I'm trying to adopt the new Photos APIs from iOS 14 but am running into issues with the new PHAccessLevelAddOnly access level.

I watched the WWDC 10652 session video expecting to see how this can be achieved with no luck so instead I tried having a go but ran into what seems to be either a bug of some kind where the .addOnly prompt is shown successfully however after writing my photo using a PHChangeRequest, the .readWrite permissions prompt is also shown. Interacting with the second prompt will trigger the same authentication closure and results in my code running twice so the image ends up being saved twice.

Code Block swift
PHPhotoLibrary.requestAuthorization(for: .addOnly) { status in
print("Status:", status.rawValue) // Prints twice.
if case .authorized = status {
PHPhotoLibrary.shared().performChanges({
PHAssetChangeRequest.creationRequestForAsset(from: image)
}, completionHandler: { success, error in
print("Result:", success, error ?? "nil")
})
}
}


Running the above code on iOS 14.0 using Xcode 12 GM will result in the following:
  1. The 'add only' prompt will show

  2. The image will be saved to my library

  3. The 'read write' prompt will show

  4. The closure is executed again so my image is saved twice

Am I doing something wrong? Or is this a bug? There are no docs either to help here so I'm a little stuck.
Were you able to find a solution?
Have you query user album or create a new album in your code?

I faced the similar problem as you describe.
However I found that my app not only add photo but also query and create album.

I used:
Code Block
PHAssetCollection.fetchAssetCollections
PHAssetCollectionChangeRequest.creationRequestForAssetCollection

These are my usages:
Code Block
    private func getAlbum() -> PHAssetCollection? {
        let fetchOptions = PHFetchOptions()
        fetchOptions.predicate = NSPredicate(format: "title = %@", "[myAppAlbumName]")
        let collection = PHAssetCollection.fetchAssetCollections(with: .album, subtype: .any, options: fetchOptions)
        guard let firstObject = collection.firstObject else {
            return nil
        }
        return firstObject
    }
    private func createAlbum(_ completionHandler: @escaping(_ isSuccess: Bool, _ error: Error?) -> ()) {
        PHPhotoLibrary.shared().performChanges({
            PHAssetCollectionChangeRequest.creationRequestForAssetCollection(withTitle: "[myAppAlbumName]")
        }) { (isSuccess, error) in
            completionHandler(isSuccess, error)
        }
    }


After trying not call those two functions, iPhone doesn't prompt 'read write' dialog anymore!
(Both API cause the issue)

I am not happy about Apple's changes.
Even retrieve the metadata in photo require 'read write' dialog.

Developers can do much few things than before....
PHAccessLevel .addOnly triggers .readWrite permissions still after use
 
 
Q