olofd / react-native-photos-framework

A modern and comprehensive CameraRoll/iCloud-library-API for React Native 📸 📹
MIT License
220 stars 99 forks source link

No meta data returned when calling getAssets #45

Closed hanseklund closed 7 years ago

hanseklund commented 7 years ago

On a fresh project:

RNPhotosFramework.getAssets({
        includeMetaData: true,
        startIndex: 0,
        endIndex: 100,
        fetchOptions : {
          mediaTypes: ['image'],
          sourceTypes: ['userLibrary'],
          sortDescriptors : [
            {
              key: 'creationDate',
              ascending: true,
            }
          ],
        }
      }).then((data) => {
        console.log('FETCHED DATA:',data);
      }, (e) => {
        console.log('ERROR:',e);
      })

Array of ImageAssets are returned, but no creationDate or modificationDate. NSLog of params in getAssets on iOS native code(RNPFManager.m):

{
    assetDisplayStartToEnd = 1;
    endIndex = 100;
    fetchOptions =     {
        mediaTypes =         (
            image
        );
        sortDescriptors =         (
                        {
                ascending = 1;
                key = creationDate;
            }
        );
        sourceTypes =         (
            userLibrary
        );
    };
    includeMetaData = 1;
    startIndex = 0;
}

..but all the following RCTConvert calls seems to resolve to null, including this:

BOOL includeMetadata = [RCTConvert BOOL:params[@"includeMetadata"]];

My Objective C skills are limited so didn't manage to solve this. Hopefully my javascript call above is correct. Tested on React Native 0.41.0 (and 0.43.1) using react-native-photos-framework 1.0.1

hanseklund commented 7 years ago

Ok, so this was my mistake. It should be 'includeMetadata' (lower case d) and not 'includeMetaData'.

Our implementation broke when upgrading from 0.0.64 to a newer version, so it seems like that's when the implementation switched to lower case d.

Thanks for all your great work.

olofd commented 7 years ago

@hanseklund Yes! Sry about that. Changed to Metadata to be more englishly-correct.