Home > database >  iOS: Ionic angular app - capacitor camera crash after taking picture
iOS: Ionic angular app - capacitor camera crash after taking picture

Time:01-26

I'm creating Ionic Angular app and I have some functionality which should allow user to take picture. Android app works completely fine but iOS crashes while taking picture. So to add photo you have to click button in app, then if it is first time you will se permissions modal to accept camera permissions and then prompt is shown with 2 options: take photo or from gallery. I choose to take photo so I'm taking it but after clicking camera button to take photo it just crashes and kills my app.

I have all needed permissions in Info.plists: NSCameraUsageDescription, NSPhotoLibraryUsageDescription, NSPhotoLibraryAddUsageDescription

This is how code looks like:

handleAddPhoto = async () => {
    if (this.canAddPhoto()) {
        const image = await Camera.getPhoto({
            quality: 30,
            allowEditing: false,
            saveToGallery: false,
            resultType: CameraResultType.Base64,
            source: CameraSource.Prompt,
            presentationStyle: 'popover',
        });
        this.addedImages.find(el => el.src === null).src = this.sanitizeSrc(image.base64String);
        this.handleSavePhoto(['data:image/jpeg;base64,'   image.base64String]);
    }
};

Capacitor doctor:

Latest Dependencies:

  @capacitor/cli: 4.6.1
  @capacitor/core: 4.6.1
  @capacitor/android: 4.6.1
  @capacitor/ios: 4.6.1

Installed Dependencies:

  @capacitor/cli: 4.6.1
  @capacitor/core: 4.6.1
  @capacitor/ios: 4.6.1
  @capacitor/android: 4.6.1

[success] iOS looking great!            
  • Related