How to reliably detect user-modified photos?

I'm developing a photo backup app.
To detect newly added or edited photos since the app launched, I keep a local dictionary in the format [localIdentifier: modification_date].

However, PHAsset.modificationDate is not reliable.
It often changes unexpectedly, possibly due to system operations like iCloud metadata updates.

Is there a more reliable way to detect whether a photo has been modified by user since the last app launch?

I'm thinking about using content hash instead, but I'm not sure how heavy this operation is in terms of performance.

Answered by DTS Engineer in 849584022

Using a content hash is probably the most reliable way to determine if an image file has been modified. Though, you're right, it is an expensive operation. Especially if you're trying to track a lot of photos. To avoid the overhead of decoding the image data, I expect you'd want to access the raw image data using the PHAssetResourceManager class.

Using a content hash is probably the most reliable way to determine if an image file has been modified. Though, you're right, it is an expensive operation. Especially if you're trying to track a lot of photos. To avoid the overhead of decoding the image data, I expect you'd want to access the raw image data using the PHAssetResourceManager class.

Since there are no public APIs for that, anything I can tell you about manually triggering system sync's is undocumented and subject to change without notice (not anything you'd want to build into shipping products).

I think the better way to go here is to file enhancement requests asking for features supporting your particular use case. You can file an enhancement request using the Feedback Assistant. If you file the request, please post the Feedback number here so we can make sure it gets routed to the right team.

If you're not familiar with how to file enhancement requests, take a look at Bug Reporting: How and Why?

How to reliably detect user-modified photos?
 
 
Q