fetchAssetsWithLocalIdentifiers:options: My Photo Stream not working

If I fetch PHAssets from PHAssetCollection of a subtype PHAssetCollectionSubtypeAlbumMyPhotoStream, I can enumerate them and get for every PHAsset its thumbnail and everything.

But if I try to get those My Photo Stream assets by their localIdentifier via fetchAssetsWithLocalIdentifiers:options: I get no results.

Any help will be appreciated.

Same here but one deviation:

Ironically, my fetch result is only missing the assets that did originate from the device where the -fetchAssetsWithLocalIdentifier:options: is called from.

I also noticed that the same local asset had a different localIdentifier when getting it via

[PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options: nil];

instead of

[PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum
                                         subtype:PHAssetColectionSubtypeAlbumMyPhotoStream
                                         options:nil]


i.e. testing these two assets with isEqual: gives NO. Whereas when getting an asset that originated from another device via these means I get identical localIdentifiers.


I was also wondering if there is some trick you would have to apply to a PHFetchOptions instance to get the assets missing within the fetch result to be considered at all (like .includeSourceTypes).

Same problem :

PHFetchOptions *onlyImagesOptions = [PHFetchOptions new];
onlyImagesOptions.predicate = [NSPredicate predicateWithFormat:@"mediaType = %i", PHAssetMediaTypeImage]; /
onlyImagesOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:YES]]; /
PHFetchResult *assetsFetchResult = [PHAsset fetchAssetsInAssetCollection:self.assetCollection options:onlyImagesOptions];
for (PHAsset* asset in assetsFetchResult) {
    // Assets are OK here
    [self.assets addObject:asset];

    // If I try to get the asset with its localIdentifier
   PHFetchResult* fetchResult = [PHAsset fetchAssetsWithLocalIdentifiers:@[asset.localIdentifier] options:nil];
   // No result... fetchResult.count == 0

}


Currently with have this problem with one device (ios 9.3.1) and it's appear after the upgrade to 9.3.1

No one has solution ?

I'm facing the same issue.

This is code i use to avoid this bug


extension PHAsset
{
    public class func ah_fetchAssetWithLocalIdentifier(identifier: String, options: PHFetchOptions?) -> PHAsset?
    {
        if let asset = PHAsset.fetchAssetsWithLocalIdentifiers([identifier], options: options).lastObject as? PHAsset
        {
            return asset
        }
       
        var result : PHAsset?
       
        let userAlbums = PHAssetCollection.fetchAssetCollectionsWithType(.Album, subtype: .AlbumMyPhotoStream, options: options)
       
        let fetchOptions = PHFetchOptions()
        fetchOptions.predicate = NSPredicate(format:"localIdentifier ==[cd] %@", identifier)
       
        userAlbums.enumerateObjectsUsingBlock
        {
            (objectCollection : AnyObject, _ : Int, stopCollectionEnumeration : UnsafeMutablePointer<ObjCBool>) in
           
            guard let collection = objectCollection as? PHAssetCollection else
            {
                return
            }
           
            let assetsFetchResult = PHAsset.fetchAssetsInAssetCollection(collection, options:fetchOptions)
           
            assetsFetchResult.enumerateObjectsUsingBlock
            {
                (objectAsset : AnyObject, _ : Int, stopAssetEnumeration: UnsafeMutablePointer<ObjCBool>) in
               
                guard let asset = objectAsset as? PHAsset else
                {
                    return
                }
               
                result = asset
                stopAssetEnumeration.initialize(true)
                stopCollectionEnumeration.initialize(true)
            }
        }
       
        return result
    }
}

I'm also encountered this problem,have you solved yet?


PHFetchResult* fetchResult = [PHAsset fetchAssetsWithLocalIdentifiers:@[asset.localIdentifier] options:nil];

// No result... fetchResult.count == 0

Dear White,have you solved this problem? any advice will be appreciated.


PHFetchResult *result = [PHAsset fetchAssetsWithLocalIdentifiers:localIdentifiers options:nil];

result is emtpy.

it happened to some device,not all of iOS device.maybe iOS9.3

@aspling
You should check the aurhotization to access Photo Library.
If unauthorized, the fetchAssetsWithLocalIdentifiers:options: method returns the PHUnauthorizedFetchResult instance.
If authorized, PHFetchResult instance is returned.
fetchAssetsWithLocalIdentifiers:options: My Photo Stream not working
 
 
Q