terikon / cordova-plugin-photo-library

Maintainer needed. Please contact if you're using this library in your project
MIT License
149 stars 300 forks source link

Wrong return format #175

Open Tonysmark opened 5 years ago

Tonysmark commented 5 years ago

"@ionic-native/photo-library": "^5.12.0", "cordova-plugin-photo-library": "^2.2.1", "@angular/common": "~8.1.2", "@capacitor/core": "^1.1.1", "@ionic/angular": "^4.8.0",

In the index.d.ts file claim that getLibrary(options?: GetLibraryOptions): Observable<LibraryItem[]>; this shuould return this format. but It's not!!!!!! If I'm using this code in my project

this.photoLibrary.getLibrary().subscribe(
    libaryItem =>console.log(JSON.stringify(libaryItem))
)

Then I will see this in my console

I/Capacitor/Plugin/Console: {"library":[.....]}

Witch is not right in the declearion this my couse app crash when I use libaryItem.forEach()

Tonysmark commented 5 years ago

Here is the demo in the documentation https://ionicframework.com/docs/native/photo-library

this.photoLibrary.requestAuthorization().then(() => {
  this.photoLibrary.getLibrary().subscribe({
    next: library => {
      library.forEach(function(libraryItem) {
        console.log(libraryItem.id);          // ID of the photo
        console.log(libraryItem.photoURL);    // Cross-platform access to photo
        console.log(libraryItem.thumbnailURL);// Cross-platform access to thumbnail
        console.log(libraryItem.fileName);
        console.log(libraryItem.width);
        console.log(libraryItem.height);
        console.log(libraryItem.creationDate);
        console.log(libraryItem.latitude);
        console.log(libraryItem.longitude);
        console.log(libraryItem.albumIds);    // array of ids of appropriate AlbumItem, only of includeAlbumsData was used
      });
    },
    error: err => { console.log('could not get photos'); },
    complete: () => { console.log('done getting photos'); }
  });
})
.catch(err => console.log('permissions weren\'t granted'));

And here is what Error I've got

"Uncaught TypeError: library.forEach is not a function"