2 Replies Latest reply on Jan 22, 2017 1:07 PM by davidl41577219

    IOS Camera issue in Phonegap Build


      Upon calling navigator.camera.getPicture, my app is suspending and restarting. The app works as intended in the developer app and it works like a charm on my Android device on both developer app and through Phonegap Build. The issue is strictly on the IPhone 5 SE after building the app with Phonegap Build.


      I am inspecting the app with Safari Inspector and I can't get any errors out of the console since the console exits as soon as the app does.


      What's more, I resorted to building this example build at GitHub - phonegap-build/pgb-example-camera: Camera Example App and it does the exact same thing.


      Here is my config.xml file:


      I included the <variable name="CAMERA_USAGE_DESCRIPTION'> and the <feature name="Camera"> at the suggestions of other posts, but it hasn't helped with or without.


      <?xml version="1.0" encoding="UTF-8" ?>
      <widget xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" id="com.phonegap.helloworld" version="1.0.0">
        <preference name="orientation" value="portrait" />
        <preference name="loadUrlTimeoutValue" value="700000" />
        <preference name="exit-on-suspend" value="false" />
        <author href="http://phonegap.com" email="support@phonegap.com">PhoneGap Team</author>
        <content src="index.html"/>
        <preference name="DisallowOverscroll" value="true"/>
        <preference name="android-minSdkVersion" value="14"/>
        <preference name="fullscreen" value="true" />
        <preference name="webviewbounce" value="false" />
        <feature name="Camera">
          <param name="ios-package" value="CDVCamera" />
        <plugin name="cordova-plugin-battery-status" source="npm" spec="~1.1.1"/>
        <plugin name="cordova-plugin-camera" source="npm" spec="~2.1.1"><variable name="CAMERA_USAGE_DESCRIPTION" value="take pictures" /></plugin>
        <plugin name="cordova-plugin-media-capture" source="npm" spec="~1.2.0"/>
        <plugin name="cordova-plugin-console" source="npm" spec="~1.0.2"/>
        <plugin name="cordova-plugin-contacts" source="npm" spec="~2.0.1"/>
        <plugin name="cordova-plugin-device" source="npm" spec="~1.1.1"/>
        <plugin name="cordova-plugin-device-motion" source="npm" spec="~1.2.0"/>
        <plugin name="cordova-plugin-device-orientation" source="npm" spec="~1.0.2"/>
        <plugin name="cordova-plugin-dialogs" source="npm" spec="~1.2.0"/>
        <plugin name="cordova-plugin-file" source="npm" spec="~4.1.1"/>
        <plugin name="cordova-plugin-file-transfer" source="npm" spec="~1.5.0"/>
        <plugin name="cordova-plugin-geolocation" source="npm" spec="~2.1.0"/>
        <plugin name="cordova-plugin-globalization" source="npm" spec="~1.0.3"/>
        <plugin name="cordova-plugin-inappbrowser" source="npm" spec="~1.3.0"/>
        <plugin name="cordova-plugin-media" source="npm" spec="~2.2.0"/>
        <plugin name="cordova-plugin-network-information" source="npm" spec="~1.2.0"/>
        <plugin name="cordova-plugin-splashscreen" source="npm" spec="~3.2.1"/>
        <plugin name="cordova-plugin-statusbar" source="npm" spec="~2.1.2"/>
        <plugin name="cordova-plugin-vibration" source="npm" spec="~2.1.0"/>
        <plugin name="cordova-plugin-whitelist" source="npm" spec="~1.2.1"/>
        <allow-navigation href="*" />
        <access origin="*" subdomains="true" />
        <allow-intent href="*"/>
        <allow-intent href="http://*/*"/>
        <allow-intent href="https://*/*"/>
        <allow-intent href="tel:*"/>
        <allow-intent href="sms:*"/>
        <allow-intent href="mailto:*"/>
        <allow-intent href="geo:*"/>
        <platform name="android">
          <allow-intent href="market:*"/>
        <platform name="ios">
          <allow-intent href="*"/>
          <allow-intent href="itms-apps:*"/>


      My javascript for taking the picture(works just fine in every other scenario):


      function takePicture(){
        console.log("attempt to take picture");
        navigator.camera.getPicture(onCameraSuccess, onCameraFail, 
        quality: 50,
        destinationType: Camera.DestinationType.DATA_URL,
        correctOrientation: true,
        encodingType: Camera.EncodingType.JPEG,
        sourceType: Camera.PictureSourceType.PICTURE
        console.log("after picture");


      Here is my content security policy. Could this be part of the problem?


      <meta http-equiv=Content-Security-Policy: "default-src *; script-src * 'self' 'unsafe-inline' 'unsafe-eval'; object-src *; style-src * 'self' 'unsafe-inline' 'unsafe-eval'; img-src *; media-src *; frame-src *; font-src *; connect-src *"
          X-Content-Security-Policy: "default-src * gap://ready file:; script-src *; object-src *; style-src *; img-src *; media-src *; frame-src *; font-src *; connect-src *"
          X-WebKit-CSP: "default-src *; script-src *; object-src *; style-src *; img-src *; media-src *; frame-src *; font-src *; connect-src *" />



      This problem is driving me crazy. No one else on the internet has had a similar problem and I've got three google search pages of purple links for every combination of keywords relating to my problem.


      Thanks for reading any any thoughts to point me in the right direction would be amazing.

        • 1. Re: IOS Camera issue in Phonegap Build
          VectorP Level 4

          I am guessing a bit, here, but I assume that your device doesn't like a combination of settings from your config.


          You should:

          - remove the FEATURE element. It shouldn't be there.

          - remove that VARIABLE element for now

          - use the latest version of the Camera plugin. Don't pin an older version

          - when you're at it, also remove the spec attribute of the other plugins, so you'd not be stuck with older versions

          - remove all plugins that could possibly collide with the Camera plugin, such as the media-capture plugin



          • 2. Re: IOS Camera issue in Phonegap Build
            davidl41577219 Level 1

            Thank you Vector, you have saved the day.


            For anyone wondering, I removed the FEATURE and VARIABLE elements and removed the spec attribute on all of the plugins. I also removed the media and media capture plugin. I didn't narrow down the exact cause of the problem but it is a combination of those things.