Post

Replies

Boosts

Views

Activity

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. 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: The 'add only' prompt will show The image will be saved to my library The 'read write' prompt will show 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.
2
0
1.4k
Sep ’20