我需要在 android && ios 上制作一个类似应用程序的图库。当用户打开应用程序时,用户应该看到手机中的图像并选择它们。我不想使用使用意图的图像选择器。是否可以在cordova phonegap或类似混合框架的Ionic上构建此程序,或者我应该使用本机android ios?
实际上我们可以像这样从设备中获取照片;使用离子 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 => {},
complete: () => { console.log('could not get photos'); }
});
})
.catch(err => console.log('permissions weren't granted'));`
不要忘记像这样在app.module上导入库
import { PhotoLibrary } from '@ionic-native/photo-library';