I'm working on an Ionic app which uses geolocation and based on my config.xml and an extra edit-config element, I'm getting the following three keys in my info.plist file:
The LocationWhenInUse key is something I'm adding but the other two are coming in from somewhere else. Here's my relevant config.xml:
...
<platform name="ios">
<edit-config file="*-Info.plist" mode="merge" target="NSLocationWhenInUseUsageDescription">
<string>Location will be used while app is in use.</string>
</edit-config>
...
</platform>
...
<plugin name="cordova-plugin-geolocation" spec="^4.0.1">
<variable name="GEOLOCATION_USAGE_DESCRIPTION" value="Geolocation will be used to determine your location" />
</plugin>
What I would like to do is remove the two "Always" permissions. The only thing I want to ask the user is Never/When In Use.
Is there any way I can just remove the two "always" elements using the config.xml? I don't want to have to remember to remove those two keys every time I do a production iOS build.
These keys are placeholders added by cordova-diagnostic-plugin.
The strings contained within NSLocationAlwaysUsageDescription
and NSLocationAlwaysAndWhenInUseUsageDescription
will only be displayed if you request to use location "Always" at runtime.
Update
To remove those keys from the .plist
, you could use cordova-custom-config. First install it:
cordova plugin add cordova-custom-config
Then add <custom-config-file>
blocks under <platform name="ios">
to delete the unwanted keys:
<platform name="ios">
<custom-config-file parent="NSLocationAlwaysUsageDescription" target="*-Info.plist" mode="delete"/>
<custom-config-file parent="NSLocationAlwaysAndWhenInUseUsageDescription" target="*-Info.plist" mode="delete"/>