I am building an app that shares photos between iOS/macOS users through the cloud shared album of the Photos application. I need each photo to be described by a few numbers carrying app-specific parameters.
I was researching through several ideas, none of which worked:
Writing numbers (or strings) into EXIF or IPTC meta-data fields
Inserting numbers into the photo filename eg IMG_1234-i1-i2-...-iN.JPEG
Saving integers parallelly in an iCloud along with a photo identifier, so data can be retrieved on each device using the photo identifier
PHObject.localIdentifier
is not persistent across the cloud shared albums read on different devices. I did not check this, but why otherwise the identifier
would be called local
? Is there any working way to bind a small amount of data to the photo in Cloud Shared Album of iOS/macOS Photos app ?
Following a description of a private API which I found in this answer I created the following extension to PHAsset:
extension PHAsset {
var cloudIdentifier: String {
return (self.value(forKey: "cloudIdentifier") as? String) ?? "?"
}
}
The cloudIdentifier
which you can get now from a PHAsset
instance is persistent throughout the cloud on any devices sharing the same album. With persistent PHAsset identifier, one can implement solution #3 from the initial question.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.