Cordova Info.plist NSCameraUsageDescription Key Is Missing


Answer :

NEW ANSWER:



Since Cordova CLI 6.5.0 you can write in the info.plist directly by using the edit-config tag in the config.xml like this:



    <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 the config.xml using the config-file tag yet (it's being worked on)



Latest version of the camera plugin allows you to add the NSCameraUsageDescription when you install the plugin



cordova plugin add cordova-plugin-camera --variable CAMERA_USAGE_DESCRIPTION="your usage message"



Right now it's not possible to localize this string



Here are results of my own research:





    • Yes, you can modify info.plist from the config.xml file
      using the config-file tag, but you have to use a plugin for that
      (cordova custom config) and follow the instructions religiously.

    • However, probably a better option is to use plugin.xml to do the same thing. More about it you can read here (modifying info plist from plugin.xml)

    • Another option as @jcesarmobile mentioned - current camera plugin may support it like cordova plugin camera (this solution is specific to the plugin)



    • Yes, it is possible to localize a string inside the info.plist file but it requires to use xcode for that. I'm not sure how to localize a string inside the info.plist file using Cordova config.xml or plugin.xml




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. :)



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:



<plugin name="cordova-plugin-ios-camera-permissions" >
<variable name="CAMERA_USAGE_DESCRIPTION" value="YOUR-PERMISSION-REQUEST" />
<variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="YOUR-PERMISSION-REQUEST" />
</plugin><!-- spec="1.0.3" !-->

<plugin name="cordova-plugin-camera" >
<variable name="CAMERA_USAGE_DESCRIPTION" value="YOUR-PERMISSION-REQUEST" />
<variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="YOUR-PERMISSION-REQUEST" />




<gap:plugin name="cordova-plugin-image-picker" source="npm" />
<gap:plugin name="cordova-plugin-base64-joewsh" source="npm" /> <!-- convertir a base64 los files !-->


<gap:plugin name="cordova-plugin-barcodescanner" source="npm" spec="0.7.0" >

<variable name="CAMERA_USAGE_DESCRIPTION" value="YOUR-PERMISSION-REQUEST" />
</gap:plugin>


2) add this code (remember to use the same string in the variables, as I mention before):



<platform name="ios">

<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge" overwrite="true">
<string>YOUR-PERMISSION-REQUEST</string>
</edit-config>
<edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="merge" overwrite="true" >
<string>YOUR-PERMISSION-REQUEST</string>
</edit-config>
<edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge" overwrite="true">
<string>YOUR-PERMISSION-REQUEST</string>
</edit-config>
</platform>


Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable