Search code examples
iosgeolocationionic3policy

ionic 3 - iOS policy location permission modal alert message


I develop an app that uses geolocation for iOS using Ionic 3. The app was rejected I need to change the app request for location message.

Screenshot of location request message

I follow the iOS quirk mention in cordova geolocation plugin page without luck:

<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
    <string>need location access to find things nearby</string>
</edit-config>

I tried another variable NSLocationAlwaysUsageDescription, and both variables. I uninstall and install again the geolocation plugin. I try many answer to "similar" questions but nothing seems to work.

Somethings to note:

  • I also use BackgruondGeolocation plugin.
  • Part of the packages

    “@ionic-native/background-geolocation”: “^4.12.2”, “@ionic-native/core”: “~4.11.0” “@ionic-native/geolocation”: “^4.12.0”, … “ionic-angular”: “3.9.2”

  • I notice that if i add the <edit-config> entry at the end of <platform name="ios"> it gives me a conflict message when building but it ends, no message if it is at the start. It does not work either way.

Please someone help me.


Solution

  • According to the documentation, you have to add this key to your Info.plist :

    NSLocationWhenInUseUsageDescription, NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationAlwaysUsageDescription

    You are required to include the NSLocationWhenInUseUsageDescription and NSLocationAlwaysAndWhenInUseUsageDescription keys in your app's Info.plist file. (If your app supports iOS 10 and earlier, the NSLocationAlwaysUsageDescription key is also required.) If those keys are not present, authorization requests fail immediately.