Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong return format #175

Open
Tonysmark opened this issue Aug 27, 2019 · 1 comment
Open

Wrong return format #175

Tonysmark opened this issue Aug 27, 2019 · 1 comment

Comments

@Tonysmark
Copy link

"@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
Copy link
Author

Tonysmark commented Aug 27, 2019

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant