Greg4572
Greg4572

Reputation: 41

Unable to change NSCameraUsageDescription in Config.xml

I have been trying to solve this issue for the last few days, as it is preventing me from deploying an update to the iOS app store. When i try one of the solutions i find and build the .ipa file, then i go and check the .plist file but the NSCameraUsageDescription property never shows the custom message i am trying to display.

I cant tell if i am doing it wrong as i have done almost everything i can find to solve this. So far i have tried this solution and a few others that just change the the format to how the property is set. I have also done an upgrade to the cordova version so i could use the latest version of the camera plugin to try fix this as well.

Here is my current Config.xml file: (commented parts are other methods i have tried.)

<widget xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" id="com.devexpress.apptemplate" version="1.0" versionCode="1" xmlns:android="http://schemas.android.com/apk/res/android">
  <name>ApplicationTemplate</name>
  <preference name="prerendered-icon" value="true" />
  <preference name="android-windowSoftInputMode" value="adjustPan" />
  <preference name="SplashScreen" value="splash" />
  <preference name="SplashScreenDelay" value="3000" />
  <preference name="FadeSplashScreen" value="false" />
  <preference name="FadeSplashScreenDuration" value="2000" />
  <preference name="SplashShowOnlyFirstTime" value="false" />
  <preference name="DisallowOverscroll" value="true" />
  <preference name="StatusBarOverlaysWebView" value="false" />
  <preference name="StatusBarBackgroundColor" value="#000000" />
  <preference name="android-minSdkVersion" value="16" />
  <preference name="android-targetSdkVersion" value="26" />
  <preference name="android-build-tool" value="gradle" />
  <preference name="iosPersistentFileLocation" value="Compatibility" />
  <preference name="AndroidPersistentFileLocation" value="Compatibility" />
  <preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external,assets,root" />

  <preference name='phonegap-version' value='cli-7.1.0' />
  <preference name='pgb-builder-version' value='1' />

  <feature name="http://api.phonegap.com/1.0/network" />

  <config-file platform="android" parent="/manifest" mode="add">
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAMERA" />
  </config-file>

  <platform name="ios">
    <preference name="CAMERA_USAGE_DESCRIPTION" default=" " />
    <config-file target="*-Info.plist" parent="NSCameraUsageDescription">
      <string>Camera is used for uploading activation photos and profile pictures.</string>
    </config-file>
    <preference name="PHOTOLIBRARY_USAGE_DESCRIPTION" default=" " />
    <config-file target="*-Info.plist" parent="NSPhotoLibraryUsageDescription">
      <string>Photo Library is used for uploading activation photos and profile pictures.</string>
    </config-file>
   </platform>


   <!--<edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="overwrite">
    <string>Camera is used for uploading activation photos and profile pictures.</string>
  </edit-config>-->

    <!--<platform name="ios">
    <edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge">
      <string>Camera is used for uploading activation photos and profile pictures.</string>
    </edit-config>
    <edit-config target="NSPhotoLibraryUsageDescription" file="Info.plist" mode="merge">
      <string>Photo Library is used for uploading activation photos and profile pictures.</string>
    </edit-config>
  </platform>-->

  <preference name="ShowSplashScreenSpinner" value="false" />
  <author email="[email protected]" href="address.com">Description</author>

  <gap:plugin name="cordova-plugin-camera" version="4.0.3" source="npm" />
  <gap:plugin name="cordova-plugin-device" version="1.1.5" source="npm" />
  <gap:plugin name="cordova-plugin-file" version="4.2.0" source="npm" />
  <gap:plugin name="cordova-plugin-file-transfer" version="1.5.1" source="npm" />
  <gap:plugin name="cordova-plugin-geolocation" version="2.4.2" source="npm" />
  <gap:plugin name="cordova-plugin-network-information" source="npm" />
  <gap:plugin name="cordova-plugin-splashscreen" version="3.2.2" onload="true" source="npm" />
  <gap:plugin name="cordova-plugin-whitelist" source="npm" />
  <gap:plugin name="cordova-plugin-ios-longpress-fix" version="1.1.0" source="npm" />
  <gap:plugin name="cordova-plugin-statusbar" version="2.1.3" source="npm" onload="true" />
  <gap:plugin name="ionic-plugin-keyboard" source="npm" />
  <gap:plugin name="cordova-plugin-market" source="npm" />
  <gap:plugin name="cordova-plugin-appversion" source="npm" />
  <gap:plugin name="cordova.plugins.diagnostic" source="npm" />
  <plugin name="uk.co.workingedge.phonegap.plugin.launchnavigator" source="npm" />

  <access origin="*" />
  <access origin="tel:*" launch-external="yes" />
  <access origin="geo:*" launch-external="yes" />
</widget>

Can anybody see if i am doing anything wrong? Any advice would be greatly appreciated.

Upvotes: 0

Views: 2253

Answers (4)

AlwaysLearning
AlwaysLearning

Reputation: 8809

In my experience changes to the config.xml file only get propagated when a platform gets added (or a plugin whose plugin.xml contains new permission/s).

In other words if you change an Android- or iOS-related permission or usage description and the change doesn't appear after you cordova build, cordova emulate or cordova run then you probably need to remove and re-add the appropriate platform:

  • cordova platform rm android; cordova platform add android
  • cordova platform rm ios; cordova platform add ios

Upvotes: 0

Webmavens India
Webmavens India

Reputation: 1

Maybe its late but I think its worth answering, You need to update from the Xcode itself and add the key in the info file as

Like this Sample code ScreenShot

Now check your projects's info.plist, the code should be added there like

<key>NSCameraUsageDescription</key>
<string>APPNAME requires access to your phone's camera for this PURPOSE.</string>

Now, from Xcode clean your project and build again, your app should working fine now.

I have Xcode version 10.3 and its working very fine with this solution.

Hope this help anyone!!

Upvotes: 0

Anders Borg
Anders Borg

Reputation: 72

They changed from using config-file to edit-config in cli-7.0.1 to better align with plugin.xml (well, at least that's my theory).

Read the documentation about plugin.xml for the syntax (note: it's different from config-file!): https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html

Upvotes: 0

RamY
RamY

Reputation: 492

Found the answer here.

You need to use the edit-config in config.xml. Like this:

    <edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge">
      <string>need camera access to take pictures</string>
    </edit-config>

Upvotes: 1

Related Questions