我需要在android&&和ios。当用户打开应用程序时,用户应该看到手机中的图像并选择它们。我不想使用使用Intents的图像选择器。是否可以在cordova phonegap或者类似离子的混合框架上构建这个程序,或者我应该使用原生android ios?
答案 0 :(得分:0)
`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';