Nativ camera crash by opening on iPhone device

Hi all

I use the native camera within my mobile application.

If I test my application with the Ionic DevApp, the camera is working on the device.

When I deploy my application to the ios-device, the application crashes (application is closing immediately).

Does anybody know, which possibilities I have, to see what’s the problem (any errors?) could be?
Do I have it to debug with Xcode? Is this maybe the only way?

These are my options for the camera:

    const options: CameraOptions = {
      quality: 25,
      correctOrientation: true,
      targetHeight: 1000,
      targetWidth: 1000,
      destinationType: this.camera.DestinationType.DATA_URL,
      encodingType: this.camera.EncodingType.JPEG,
      mediaType: this.camera.MediaType.PICTURE
    }

regards,
Oliver

update:
I removed already now the whole ios-platform and added it again.
Also I removed all my plugins and added it again.

I still have the problem, that my camera crashes on opening on ios-device.

here my current environment settings:


cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.0
    ionic (Ionic CLI) : 3.19.0

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.2
    Cordova Platforms  : android 6.3.0 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    ios-deploy        : 1.9.2
    Node              : v8.9.1
    npm               : 5.6.0
    OS                : macOS High Sierra
    Xcode             : Xcode 9.2 Build version 9C40b

Environment Variables:

    ANDROID_HOME : /Users/oliverwaterkamp/Library/Android/sdk

Misc:

    backend : pro

DO a search for NSCameraUsageDescription as IOS requires this - I think you can put the entries in the config.xml file but I have yet to find an example.

Look at this post:

1 Like

hi @JAR19

Thanks for your answer.
After I started my application on the ios-device with XCode I saw an error-message like this:

This app has crashed because it attempted to access privacy-sensitive data 
without a usage description. The app's Info.plist must contain
 an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.

I think this goes exactly in that direction you mentioned above.
I will try to fix it and I hope I can solve this issue.

P.S
I’m wondering how many implemented security steps (signing, enable developer mode on device, usage descriptions…) will follow until everything is finally running :smile:

After I added following to my config.xml everything worked - Hooray!!! :-):grin:

<platform name="ios">   
 <config-file parent="NSCameraUsageDescription" platform="ios" target="*-Info.plist">
            <string>You can upload your offer/article picture using your camera</string>
        </config-file>
</platform>
6 Likes

Glad you have it working - did the device come up and ask the user to allow access to the camera?

yes, it came up with them, why?

I had the same problem last week with the microphone using cordova audioinput - but not sure how to check that the user has granted permission. I also feel that it does not look very professional - it should be part of the installation.
I think I will have to build a test app just to see how microphone access responds to no permission and if navigator.getUserMedia({audio:true, video:false} works on the iphone.

yes, that’s true. This message looks a little irritating, but for I think I the user can live with that for the moment.
My experience at the moment is not so high in Ionic (or mobile app in general), that I can give you an answer for this :wink:
I have to focus at the moment on others things on my list :slight_smile:
But I keep my eye on this and let you know if I would find out something.

I just tried that in a new blank project and the plist file was not updated - strange?

In the new project xcode reports 16 warnings I have posted a new post asking if these need to be corrected.

1 Like

hmmm honestly I don’t have that much knowhow in Xcode.
I only used Xcode to deploy my application to the ios-device, to see whether it works.

As I mentioned I just added the above NSCameraUsageDescription to the config.xml,
created an another ios-build, started my XCode Environment and deployed it from there to
my device.

I didn’t have a look to my plist file, whether there was something updated or not.

I just recognised that my camera was working on the device and the policy-error (NSCameraUsageDescription)
from before disappeared.

Do we have to do something with this plist file?

Do we need this to deploy the app in the end to the store?

Like you my knowledge of xcode is very limited - I develop on a windows pc and use a mac-book just to generate the ionic app in IOS format and test it on a iPhone 5C.

Hopefully other Ionic developers who have actually deployed apps on the Apple store will join this discussion - my personal view is that if xcode brings up a warning it needs to be corrected or else it will just come back later.

1 Like

haha…I’m in the same situation as you.
I’m windows-developer normally. But to compile my mobile app also for ios-devices, I bought an Mac.
But I have to say, that I’m developing the mobile app complete on Mac in VS Code, to learn better
to understand Mac. But they are hard-times at the moment, especially the shortcuts are pain :wink:

I solved it by checking if the camera is available or not. Link: https://ionicframework.com/docs/native/diagnostic/

this Issue may Cause of camera permission in ionic checkout this link it may help you to solve this issue