'requestImageForAsset' often returns nil for iCloud Photo Library

I have tried every combination of PHImageRequestOptions and I still am not able to reliably fetch some (maybe 10-20%) of iCloud photos with a higher resolution than a thumbnail. The strange thing is that if I go into the Photos app and try to view those photos it will download them there and then I am able to retrieve them, even stranger is that some images never load in the Photos app either. Is there a trick to reliably download iCloud photos at higher resolutions? or a way to tell the image can not be accessed?


FYI I never get an error in the returning info, only something along the lines of:

PHImageResultDeliveredImageFormatKey = 9999;

PHImageResultIsDegradedKey = 0;

PHImageResultIsInCloudKey = 1;

PHImageResultIsPlaceholderKey = 0;

PHImageResultRequestIDKey = 52;

PHImageResultWantedImageFormatKey = 9999;



Thanks!

Replies

I missed your question when I posted my own (https://forums.developer.apple.com/thread/16244). Have you figured anything out?

You've probably already done this, but it's worth double-checking - do you have networkAccessAllowed turned on?

PHImageResultIsInCloudKey is how you know that a photo is unavailable because it's in the cloud when networkAccessAllowed is turned off. I forgot to set it myself once and spent a half a day debugging this issue before I realized it was behaving as expected.


That being said, I've also seen responses like this when networkAccessAllowed IS on, so there are definitely some bugs where PhotoKit doesn't give you a photo OR a meaningful error message. There are a handful of other discussions on the forum about that issue so hopefully Apple will keep ironing out these issues. (https://forums.developer.apple.com/thread/16244,https://forums.developer.apple.com/thread/13830)