iCloud sync of images in Photos Framework created

2019-05-24 11:18发布

TL;DR - Will an album created with [PHAssetCollectionChangeRequest creationRequestForAssetCollectionWithTitle:@"ALBUM_TITLE"]; sync over iCloud? And will synced images have the same localIdentifier on every device?

In my App I need to store a number of distinct albums/folders of photos that the user adds by either using the camera or adding an existing photo from the photo library. Ideally what I want is all the photos from the app to be located in the same one (specific to my app) album in the Photos app, for this album to sync over iCloud, and for me to be able to store references to the specific photos in this album so I can then resort these photos to the separate albums in my app.

I can create an album for the images, store the image's localIdentifier's in an array and use fetchAssetsWithLocalIdentifiers:options: to get the images.

The problem is getting these images to sync over iCloud. Will an album I create using [PHAssetCollectionChangeRequest creationRequestForAssetCollectionWithTitle:@"ALBUM_TITLE"]; sync over iCloud? From what I can tell, if the user doesn't have iCloud Photo Library enabled then it won't sync, but it will sync with iCloud Photo Library, is that correct?

If it will sync over iCloud, will the localIdentifier for the images in the album be the same, or will these get a new identifier when they download to a new device? If they do get new identifiers how can I store a reference to specific images that will persist across devices?


Note: I havn't got access to an iCloud enabled device to test this for now

1条回答
贼婆χ
2楼-- · 2019-05-24 11:59

After testing it seems that any PHAssets created will sync over iCloud. (I've only tested this with iCloud Photo Library turned on so not 100% sure otherwise).

It also seems that the localIdentifier of PHAssets are exactly what they say: local, and won't persist across devices.

查看更多
登录 后发表回答