Open Tonysmark opened 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"
"@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 thatgetLibrary(options?: GetLibraryOptions): Observable<LibraryItem[]>;
this shuould return this format. but It's not!!!!!! If I'm using this code in my projectThen I will see this in my console
Witch is not right in the declearion this my couse app crash when I use
libaryItem.forEach()