Does PHAsset localIdentifier change after device transfer?

Hi, I’m working on a photo backup app.

I track the PHAsset localIdentifier to determine which photos have been backed up and which haven’t.


Recently, I’ve noticed that two users seem to have experienced the localIdentifier changes after transferring data to a new iPhone using Quick Start.

Additionally, others on StackOverflow have mentioned that the localIdentifier sometimes changes after updating the iOS version.

https://stackoverflow.com/questions/40094728/phobject-localidentifier-reliability


I’d like to confirm the reliability of the localIdentifier after an iOS version upgrade or device transfer.

Can I continue using these locally stored localIdentifiers?

Or is there another recommended approach, such as using PHCloudIdentifier?

The clue is in the name, isn’t it? I would not expect a “local identifier” to be valid on a different device.

The change on iOS update seems less reasonable.

Yes it is expected that the localIdentifier may change under various circumstances such as you are describing. The recommendation would be to use PHCloudIdentifier for your use case.

From the PHCloudIdentifier documentation: https://developer.apple.com/documentation/photos/phcloudidentifier

A local identifier is valid for referring to objects only in the context of a local device.

PHCloudIdentifier will also solve some other problems you may encounter building a backup app. For instance, if users of your app have it installed on multiple of their devices then you can use PHCloudIdentifier to ensure you are only backing up an Asset once. On those two devices there would be two different local identifiers for the same PHAsset in the library.

Does PHAsset localIdentifier change after device transfer?
 
 
Q