3 ms·
Ahh, I did consider PHAsset.fetchAssets but my understanding was that the method will download the file if not present locally - which wouldn't be acceptable fo
by asdaq1312512 3y ago
Ahh, I did consider PHAsset.fetchAssets but my understanding was that the method will download the file if not present locally - which wouldn't be acceptable for an app, I guess.
Do you know more? The introduction says "Retrieve asset metadata or request full asset content.", but I can't find clarification when it actually accesses full content.
- alexwlchan 3y agoYeah, that was what I thought when I first worked with these APIs! But when you use PhotoKit, you have to explicitly opt-in to downloading files from iCloud. AFAICT, PHAsset is only metadata. When I'm downloading the full-sized images, I use PHImageManager.requestImage() and pass in the PHAsset I'm looking at [1][2]. I know there's something similar for video, but I've never used it. You can control the behaviour by passing a PHImageRequestOptions instance. This includes an isNetworkAccessAllowed bool which controls where Photos.app will download the file from iCloud if not present locally, and it defaults to false. [1]: https://developer.apple.com/documentation/photokit/loading_and_caching_assets_and_thumbnails https://developer.apple.com/documentation/photokit/loading_a... [2]: https://developer.apple.com/documentation/photokit/phimagemanager#1656241 https://developer.apple.com/documentation/photokit/phimagema... [3]: https://developer.apple.com/documentation/photokit/phimagerequestoptions/1616934-isnetworkaccessallowed https://developer.apple.com/documentation/photokit/phimagere...