After recent changes Apple requires specific keys if your app attempts to access privacy-sensitive data. So I added NSCameraUsageDescription key in my config.xml like this:
<platform name="ios">
<config-file parent="NSCameraUsageDescription" target="*-Info.plist">
<string>We are using a camera to </string>
</config-file>
</platform>
Then
cordova build ios --release --device
produces the ipa which apparently doesn't have the right info in info.plist. It feels like I'm missing something.
Question 1: What do I need to put into config.xml to solve NSCameraUsageDescription issue? Question 2: Is it possible to use localization for this string?
Thank you!
Here are results of my own research:
Please, correct me if I wrong. More info on the localization directly from config.xml is appreciated.
Personally, I don't like the idea to use a custom plugin to modify an info.plist file. It feels like with every new plugin I use make my app more and more fragile. :)
You need to read inside of ./plugins/plugin-what-ever/plugin.xml to see what kind of key names are supported.
Go to your project >> Open Terminal there
and run this command
You can keep modify the values "Allow the app to use your camera" "Allow the app to access your photos" according to your need.
First, this works for me with Cli-7.1.0 after apple rejects my ipa.
1) In your code, if you use for ex. cordova-plugin-barcodescanner and cordova-plugin-camera and cordova-plugin-ios-camera-permissions all the variables CAMERA_USAGE_DESCRIPTION, PHOTOLIBRARY_USAGE_DESCRIPTION should have the same string inside. If one of them is different apple rejects your ipa, because phonegap use the default variable .
ej:
2) add this code (remember to use the same string in the variables, as I mention before):
For iOS 10/11, you can use cordova-plugin-ios-camera-permissions as a shortcut.
Provides defaults and clear documentation for how to provide customized messages.
If you have already setup iOS platform, removing and re-adding may be required.
NEW ANSWER:
Since Cordova CLI 6.5.0 you can write in the
info.plist
directly by using theedit-config
tag in theconfig.xml
like this:<edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge"> <string>your usage message</string> </edit-config>
But make sure you are using latest version of the plugins or values might be overwritten by the plugin variables.For localizations you can use the
resource-file
tag and InfoPlist.strings files like in this plugin (but you don't need the plugin, resource-file tag is supported from the config.xml)https://github.com/MBuchalik/cordova-plugin-ios-permissions
OLD ANSWER:
You can't write on the
info.plist
from theconfig.xml
using theconfig-file
tag yet (it's being worked on)Latest version of the camera plugin allows you to add the
NSCameraUsageDescription
when you install the plugincordova plugin add cordova-plugin-camera --variable CAMERA_USAGE_DESCRIPTION="your usage message"
Right now it's not possible to localize this string