PHCloudIdentifier without photo library access prompt

Hi,

I'm currently let the user pick a photo using PHPickerViewController. The advantage of PHPickerViewController is that the user is not requested to grant photo access (no permission alerts).

After the user picked the photo I need to take note of the local identifier and the cloud identifier (PHCloudIdentifier).

For the local identifier no problem, I just use the assetIdentifier from the PHPickerResult.

For obtaining the cloud identifier (PHCloudIdentifier, on iOS 15 only) I need to use the cloudIdentifierMappings method of PHPhotoLibrary. The problem of that method is that is causing the photo library access permission alerts to display.

Someone know if there is another way to get the cloud identifier from a local identifier without having to prompt the user photo library access?

Thank you

Answered by Engineer in 701159022

You have to request photo library access to use the cloud identifier.

I would love to know your use case a little bit more. Why do you want to use the cloud identifier with PHPicker?

Accepted Answer

You have to request photo library access to use the cloud identifier.

I would love to know your use case a little bit more. Why do you want to use the cloud identifier with PHPicker?

Thank you for the answer. 

I’m developing a CoreData application that allow the user to store data and pictures. The app is doing some local backups of the CoreData store. Since pictures can make the store very large I just backup the data of the store without the pictures (I keep only the assetIdentifier). 

If for some reason the user need to restore the data from a backup, the app will try to look for the original pictures in the user library using the asset identifiers. This is working fine if the user is restoring the data on the same device, but if the backup is restored on another device the local identifiers become useless. The idea was to also store the cloud identifier so that the restore procedure has a chance to find the original pictures also on a different device. 

Now, I really don’t want to ask user to grant library access during the normal use of the app. Access will be requested only in the rare case that a restore is required.

Personally, I would love to receive the cloud identifier directly inside the PHPickerResult like the assetIdentifier. 

What do you think about it?

PHCloudIdentifier without photo library access prompt
 
 
Q