unixb0y
unixb0y

Reputation: 1048

Fetch images from iCloud Photo Library PHImageManager


I currently have an issue where users that use iCloud Photo Library and pick an image that's not locally saved, the PHImageManager returns a blank image (nothing).
Is there a specific option to automatically download images that are stored only in iCloud?
(I use a custom CollectionView and PHImageManager)

Upvotes: 2

Views: 4378

Answers (2)

David
David

Reputation: 101

You could use the 'requestImageData' to download the image from iCloud:

Swift 4:

let manager = PHImageManager.default()
let requestOptions = PHImageRequestOptions()
requestOptions.resizeMode = .exact
requestOptions.deliveryMode = .highQualityFormat;

// Request Image
manager.requestImageData(for: asset, options: requestOptions, resultHandler: { (data, str, orientation, info) -> Void in
    // Do somethign with Image Data
})

If you're already using this to download the image, it looks like you need this option to download it from iCloud: PHImageRequestOptions.isNetworkAccessAllowed

For a bit more information, you can go to this link that I found: PHImageManager requestImageData with Photos iCloud Photo Library

Upvotes: 8

Nemanja Kovacevic
Nemanja Kovacevic

Reputation: 3560

If you're having trouble getting images from iCloud via PHImageManager in addition to setting PHImageRequestOptions.isNetworkAccessAllowed make sure you're not connected through Charles Proxy, iCloud doesn't like that for some reason...

Upvotes: 2

Related Questions