iOS geolocation message

Apple now requires all apps to deliver a customized message when requesting geolocation.

I’m using cordova-plugin-geolocation 2.4.3.

The docs say:

Since iOS 10 it’s mandatory to add a NSLocationWhenInUseUsageDescription entry in the info.plist.

NSLocationWhenInUseUsageDescription describes the reason that the app accesses the user’s location. When the system prompts the user to allow access, this string is displayed as part of the dialog box. To add this entry you can pass the variable GEOLOCATION_USAGE_DESCRIPTION on plugin install.

Example: cordova plugin add cordova-plugin-geolocation --variable GEOLOCATION_USAGE_DESCRIPTION=“your usage message”

If you don’t pass the variable, the plugin will add an empty string as value.

OK, great. in Meteor that should just be:

App.configurePlugin("cordova-plugin-geolocation", {
 	GEOLOCATION_USAGE_DESCRIPTION: "We secretly record your location and pass it on to the FBI, NSA, CIA.",

Except that doesn’t work. Not for me, anyway.

I also tried just AppendtoConfig:

     <string>blah blah blah.</string>
	 <string>more blah blah blah.</string>

But that did nothing for me either, I still get the boilerplate permission request.

Any ideas?

I was just exploring this yesterday, see Github issue here.

Try adding the following to your mobile-config.js and then rebuilding. Make sure you have removed your .meteor/local/cordova-build/ directory between builds because of this Meteor issue just to be safe.

  <edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
    <string>My app needs access to your location for navigation purposes</string>

Let know if this works for you as I will add to Meteor Guide if it does.

Awesome. It’ll have to wait until Monday, but I’ll give it a shot and let you know. Ty

@skirunman I can confirm this works for iOS, thanks a ton.

Didn’t seem to work on Android but if Google’s not making it mandatory, less of a problem.

Yes, this will only work for iOS.

On Android I think the requesting of permissions is handled at run-time automatically in the plugin by a call to the helper method requestPermission, but I did not do a full review.

Thanks @skirunman for explaining how to not have to add that information to info.plist myself every time.

I tried the same for another key and it seemed to also work:

  <edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="merge">
    <string>Give me a reason.</string>

This worked for me on ios as well, thank you.