When trying to grab a photo from my iOS simulator camera roll, I am getting this error:
Error: Uncaught (in promise): Error: Error loading image
This is my code to grab the photos:
//Import the plugins
import { Camera, CameraSource, CameraResultType } from '@capacitor/camera';
//Allow the user to select where the image will originate from
async selectImageSource(location: string) {
const actionSheet = await this.actionSheetController.create({
header: "Select Image Location",
buttons: [
{
text: 'Load from Library',
handler: () => {
this.choosePicture(CameraSource.Photos, location);
}
},
{
text: 'Use Camera',
handler: () => {
this.choosePicture(CameraSource.Camera, location);
}
},
{
text: 'Cancel',
role: 'cancel'
}
]
});
await actionSheet.present();
}
//Get the photo from the source location
async choosePicture(source: CameraSource, location: string) {
// Take a photo
const capturedPhoto = await Camera.getPhoto({
resultType: CameraResultType.Uri,
source: source,
allowEditing: true,
quality: 75
});
console.log(capturedPhoto); //Nothing is logged.
}
Any thoughts on what may be cause the error? Additionally, with the capacitor plugin, are iOS users required to provide permission for each photo they would want to use from their Camera Roll?
EDIT:
Here are my apps dependecies:
"dependencies": {
"@angular/common": "~12.0.1",
"@angular/core": "~12.0.1",
"@angular/forms": "~12.0.1",
"@angular/platform-browser": "~12.0.1",
"@angular/platform-browser-dynamic": "~12.0.1",
"@angular/router": "~12.0.1",
"@capacitor/app": "1.0.2",
"@capacitor/camera": "^1.0.3",
"@capacitor/core": "^3.1.2",
"@capacitor/haptics": "1.0.2",
"@capacitor/ios": "3.1.1",
"@capacitor/keyboard": "1.0.2",
"@capacitor/splash-screen": "^1.0.2",
"@capacitor/status-bar": "^1.0.2",
"@capacitor/storage": "^1.0.3",
"@ionic-native/core": "^5.34.0",
"@ionic-native/onesignal": "^5.34.0",
"@ionic-native/social-sharing": "^5.34.0",
"@ionic/angular": "^5.5.2",
"cordova-plugin-x-socialsharing": "^6.0.3",
"es6-promise-plugin": "^4.2.2",
"onesignal-cordova-plugin": "^2.11.4",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.11.4"
},