15

My ionic application for iOS worked fine, till today when I wanted to make a new build.

This is what get's returned by Apple:

Dear developer,

We have discovered one or more issues with your recent delivery for "AppName". To process your delivery, the following issues must be corrected:

This app attempts to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data.

This app attempts 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.

Though you are not required to fix the following issues, we wanted to make you aware of them:

Missing Push Notification Entitlement - Your app includes an API for Apple's Push Notification service, but the aps-environment entitlement is missing from the app's signature. To resolve this, make sure your App ID is enabled for push notification in the Provisioning Portal. Then, sign your app with a distribution provisioning profile that includes the aps-environment entitlement. This will create the correct signature, and you can resubmit your app. See "Provisioning and Development" in the Local and Push Notification Programming Guide for more information. If your app does not use the Apple Push Notification service, no action is required. You may remove the API from future submissions to stop this warning. If you use a third-party framework, you may need to contact the developer for information on removing the API.

This are my dependencies:

  • "ngstorage": "~0.3.10",
  • "ion-image-lazy-load": "*",
  • "ngCordova": "~0.1.24-alpha",

And I use the Barcode scanner in ngCordova. So I did this: $ cordova plugin rm phonegap-plugin-barcodescanner $ cordova plugin add phonegap-plugin-barcodescanner --variable CAMERA_USAGE_DESCRIPTION="Scan QR-Codes" --save

The config.xml has this in the bottom now:

 <plugin name="cordova-plugin-camera" spec="~1.2.0">
        <variable name="CAMERA_USAGE_DESCRIPTION" value="description" />
        <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="description" />
    </plugin>
    <plugin name="phonegap-plugin-barcodescanner" spec="https://github.com/phonegap/phonegap-plugin-barcodescanner.git">
        <variable name="CAMERA_USAGE_DESCRIPTION" value="Scan QR-Codes" />
    </plugin>

But still I get the same e-mail from Apple that my app has one or more issues..

Shashank Agrawal
  • 25,161
  • 11
  • 89
  • 121
user1469734
  • 851
  • 14
  • 50
  • 81

6 Answers6

27

Although, almost all Cordova plugins are now updated to support user-sensitive usage description. For example, update your barcode plugin version to the latest build (as of November 7th 2016) where they added support for usage description:

<plugin name="phonegap-plugin-barcodescanner" spec="~6.0.3">

But if you don't find a plugin supporting it yet and you need to set the description in *-Info.plist then please YOU NEED TO STOP THERE

Modifying the *-Info.plist for Cordova applications are not recommended because this will require you to save that change which might get overwritten after build process. So as the clean alternative you should use cordova-custom-config.

cordova plugin add cordova-custom-config --save

Why should I use it?

While some platform preferences can be set via Cordova/Phonegap in the config.xml, many (especially ones related to newer platform releases) cannot. One solution is to manually edit the configuration files in the platforms/ directory, however this is not maintainable across multiple development machines or a CI environment where subsequent build operations may overwrite your changes.

This plugin attempts to address this gap by allowing additional platform-specific preferences to be set after the prepare operation has completed, allowing either preferences set by Cordova to be overridden or other unspecified preferences to be set. Since the custom preferences are entered into the config.xml, they can be committed to version control and therefore applied across multiple development machines, CI environments, and maintained between builds or even if a platform is removed and re-added.

Now add the following to your config.xml file under <platform name="ios"> block:

<custom-config-file parent="NSPhotoLibraryUsageDescription" platform="ios" target="*-Info.plist">
    <string>This app needs access to your Photo Library to include a screenshot with feedback foo.</string>
</custom-config-file>
<custom-config-file parent="NSCameraUsageDescription" platform="ios" target="*-Info.plist">
    <string>Allow to scan member's pass</string>
</custom-config-file>

This will automatically add those in your *-Info.plist.

Update 1 (23rd Feb 2018)

If you are using cordova-custom-config plugin version < 5 then replace custom-config-file tag with config-file.

https://github.com/dpa99c/cordova-custom-config#changes-in-cordova-custom-config5

Update 2 (19th Jan 2019)

See this answer for Cordova CLI >= 6:

https://stackoverflow.com/a/38013943/2405040

Shashank Agrawal
  • 25,161
  • 11
  • 89
  • 121
  • 2
    I've been wondering why Xcode always erases my usage descriptions after a cordova build. This answer helped me greatly, thank you @Shashank Agrawal. – ModusPwnens Oct 31 '17 at 14:15
2

I'm using phonegap plugin org.apache.cordova.camera and solution which 100% works is here :

All you have to do is put values in config.xml file and build with phonegap.

My config.xml :

<plugin name="org.apache.cordova.camera">
      <variable name="CAMERA_USAGE_DESCRIPTION" value="App would like to access the camera." />
      <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="App would like to access the library." />
  </plugin>
1

You'll have to add the NSPhotoLibraryUsageDescription and NSCameraUsageDescription into your *.plist in your xcode;

NSPhotoLibraryUsageDescription = Privacy - Photo Library Usage Description NSCameraUsageDescription = Privacy - Camera Usage Description

Then into the value just add a description for those privacy settings.

Hope it helps

Shashank Agrawal
  • 25,161
  • 11
  • 89
  • 121
Braian Mellor
  • 1,934
  • 3
  • 31
  • 50
0

Found the solution: $ cordova plugin list and re-install all plugins and read their docs of how to install them regarding the NSPhotoLibraryUsageDescription etc .

Shashank Agrawal
  • 25,161
  • 11
  • 89
  • 121
user1469734
  • 851
  • 14
  • 50
  • 81
0

You must add the key NSPhotoLibraryUsageDescription into Info.plist (in Xcode), and the value must be the reason for the user to allow camera usage (appears in the request camera confirm dialog)

Shashank Agrawal
  • 25,161
  • 11
  • 89
  • 121
-1

Add the below in your config.xml file and it'll work fine.

<gap:plugin name="cordova-plugin-media-capture" source="npm">
    <param name="CAMERA_USAGE_DESCRIPTION" value="We'd like to access your camera to let you take a photo"/>
    <param name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="We'd like to access your photo library to let you pick a photo"/>
    <param name="MICROPHONE_USAGE_DESCRIPTION" value="We'd like to access your microphone to let you record an audio"/>
</gap:plugin>

Here is the complete config.xml file for PhoneGap Build. https://github.com/moodlehq/moodlemobile-phonegapbuild/blob/master/config.xml

Khyam Shahzad
  • 139
  • 1
  • 5
  • This works only if you're using the online PhoneGap Build service from Adobe. If you're building locally, using the CLI, then you are correct, it doesn't work at all. – Laurence MacNeill Oct 10 '18 at 19:18