简体   繁体   中英

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

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! 👌

Capacitor camera version:

"@capacitor/camera": "^4.1.4"

When I have app opened on my phone with Xcode then after taking picture my Xcode shows me this:

在此处输入图像描述

I was looking everywhere to find any help with my problem but none of found solutions works for me.

So after some debugging in native code I found it. We use UXCam in our app and it was making mess with camera. As I found some logs it looks like UXCam wanted to record screen during returning from camera view to app view and it was making mess. I didn't find option to repair it because we don't need UXCam that much, so disabling UXCam fixed all issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM