Usage Descriptions for Plugins
Description
Usage descriptions can be added to the PhoneGap config file, which can be used to add xml directly to the iOS Info.plist file and Android AndroidManifest.xml files.
Discussion
PhoneGap build allows the addition of a <config-file> element in the config.xml file. This lets you add xml directly to the iOS Info.plist file and Android AndroidManifest.xml file. (See PhoneGap Modifying Manifests.)
This solves an error that you might get when submitting an app to the Apple App Store. The error complains about certain UsageDescription strings not being set in PhoneGap Build Plugins.
For example:
Camera Plugin : NSCameraUsageDescription Calendar Plugin : NSCalendarsUsageDescription
The entry into the config.xml file to set the UsageDescription strings is:
<config-file platform="ios" parent="NSCalendarsUsageDescription" mode="replace">
<string>This app will use the Calendar</string>
</config-file>NSLocationAlwaysAndWhenInUseUsageDescription
Since iOS 10, it is mandatory to provide a usage description string in the Info.plist if the app is trying to access privacy-sensitive data. When the system prompts the user to allow access, this usage description string will be displayed as part of the permission dialog box.
If you do not provide the usage description, the app will crash before showing the dialog. Keep in mind that Apple will reject apps that access private data without providing a usage description.
The NSLocationAlwaysUsageDescription describes the reason that the app is requesting access to the user's location at all times. However, this key was deprecated as of iOS 8.0. It can still be used if your app accesses location information in the background and you deploy to a target earlier than iOS 11.
For iOS 11 and later, it is recommended to add both NSLocationAlwaysUsageDescription and NSLocationAlwaysAndWhenInUseUsageDescription to your app's Info.plist file with the same message.
When either of the Geolocation, Pushwoosh, or Background Geolocation LT plugins are used, the following entries are automatically added to your project's config.xml file. This ensures that your app has all of the required Info.plist entries.
- NSLocationWhenInUseUsageDescription
- NSLocationAlwaysAndWhenInUseUsageDescription
- NSLocationAlwaysUsageDescription