简体   繁体   English

iOS:Ionic angular 应用程序 - 拍照后电容相机崩溃

[英]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.我正在创建 Ionic Angular 应用程序,我有一些允许用户拍照的功能。 Android app works completely fine but iOS crashes while taking picture. Android 应用程序完全正常,但 iOS 在拍照时崩溃。 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.因此,要添加照片,您必须单击应用程序中的按钮,然后如果这是第一次,您将使用权限模式接受相机权限,然后显示带有 2 个选项的提示:拍照或从图库中。 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我在 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:当我用 Xcode 在我的手机上打开应用程序时,然后在拍照后我的 Xcode 向我展示了这个:

在此处输入图像描述

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.我们在我们的应用程序中使用 UXCam,它让相机变得一团糟。 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.当我发现一些日志时,它看起来像 UXCam 想要在从相机视图返回到应用程序视图期间记录屏幕并且它变得一团糟。 I didn't find option to repair it because we don't need UXCam that much, so disabling UXCam fixed all issues.我没有找到修复它的选项,因为我们不需要那么多 UXCam,所以禁用 UXCam 解决了所有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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