I’m trying to get Ionic Native Photo Library to work in a blank v4 project, but I’ve been unsuccessful.
see: https://ionicframework.com/docs/native/photo-library/
Here’s what I have in the HomePage
:
scan_PhotoLibrary():Promise<Observable<LibraryItem[]>> {
const self = this;
return self.photoLibrary.requestAuthorization()
.then( ()=>{
const photolib = self.photoLibrary.getLibrary();
if (!photolib){
// photolib is ALWAYS undefined
console.warn("IonicNative PhotoLibrary: not available with this Device")
}
photolib.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'); }
});
return Promise.resolve(photolib);
})
.catch( (err)=>{
console.log(err);
return Promise.reject(err);
});
}
}
if I step through the Ionic Native code on the ios simulator, I see it returns void
when it should be some kind of Observable
:
PhotoLibrary.prototype.getLibrary = function (options) {
var _this = this;
return (function () {
if (checkAvailability(_this) === true) {
return; // <= shouldn't this return `Observable`?
}
})();
};
Any suggestions?