cordova-plugin-googlemaps icon indicating copy to clipboard operation
cordova-plugin-googlemaps copied to clipboard

Location Permission

Open jworm7 opened this issue 10 years ago • 11 comments

Loving the plugin thus far. 2 part question:

  1. Is there a way to control when the user is prompted with the permission dialog to share their location? Presently the prompt appears right when my app is loaded and I would like to ask them once it is necessary, when the map is being presented.
  2. Is there a way to only use NSLocationWhenInUseUsage and not NSLocationAlwaysUsage? Some users might be less open to have my app always tracking their location.

Thank you for the help!

jworm7 avatar Mar 23 '16 14:03 jworm7

  1. Are you talking about Android or iOS?

  2. https://github.com/transistorsoft/cordova-background-geolocation-lt

wf9a5m75 avatar Mar 23 '16 16:03 wf9a5m75

I'm talking about iOS. The image below illustrates what I'm referring to and is a rather abrupt thing to ask a user when the app initializes. Ideally I'd like to disable location services within the plugin since my app is already locating the user's position.

photo

jworm7 avatar Mar 23 '16 16:03 jworm7

I guess you call map.getMyLocation() when the app is initialized. This plugin does not request the geolocation permission automatically.

wf9a5m75 avatar Mar 23 '16 18:03 wf9a5m75

I searched across my entire project and the only areas that getMyLocation is referenced is in the plugin folder and in the platform folder both have been untouched by me.

But it appears that when I'm calling my own Geolocation function (via the cordova geolocation plugin), the permission the app is asking for is related to how the map uses geolocation. In other words, my app just asks for in app usage of the user's location but the map wants that and exterior app location permissions, since that is a greater permission ask it looks like it is defaulting to that. Is there a way to have the map without requiring location services? Thanks again for help and patience.

jworm7 avatar Mar 23 '16 19:03 jworm7

I'm calling my own Geolocation function (via the cordova geolocation plugin), the permission the app is asking

This is that the cordova-geolocation-plugin wants to permission to access the GPS, isn't it? If you don't getMyLocation() in your code, this plugin does not related thing.

And there is no way to get geolocation without permission asking.

wf9a5m75 avatar Mar 23 '16 19:03 wf9a5m75

Correct, I just want to ask for the same amount of permission as I did without the plugin (just in app usage). So I noticed that the plugin adds NSLocationAlwaysUsageDescription to the project's .plist . If I remove that entry from the .plist it doesn't ask for location permission outside of the app but then I get this error 2016-03-23 15:38:46.362 Servy[33343:934231] locationManager::didFailWithError (null) and geolocation doesn't work.

jworm7 avatar Mar 23 '16 19:03 jworm7

So actually the error was related to the simulator simulating a location. So it works now! Just to summarize when I deleted the NSLocationAlwaysUsageDescription from the .plist that specific prompt went away and only the NSLocationWhenInUseUsage prompt appeared. I assume removing <config-file target="*-Info.plist" parent="NSLocationAlwaysUsageDescription"><string>Trace your location on the map</string></config-file> will remove it from future builds. Thanks for your help.

jworm7 avatar Mar 23 '16 20:03 jworm7

I think if you get permission using cordova geolocation plugin, the permission should be shared with other libraries. Because the permissions are given by based on the application, not library. Even if the app has already the permission, but the app still requests, the someone (the geolocation plugin or something) requests for some reason. At least this plugin does not do that.

wf9a5m75 avatar Mar 23 '16 21:03 wf9a5m75

Once you have granted geolocation permission, you can use those permissions with other plugins, if you haven't granted permissions before calling map.getMyLocation(), you should be prompted to grant permissions when calling that function on Android 6+.

guillenotfound avatar Mar 23 '16 22:03 guillenotfound

@ZiFFeL1992 That is already accepted issue https://github.com/mapsplugin/cordova-plugin-googlemaps/issues/892

ghost avatar Mar 24 '16 01:03 ghost

Is possible config Location permission plugin ONLY for When Is Usage? Now, after each build, I have to delete the NSLocationAlwaysUsage in XCode directly.

Could you help us?

globalsysdesenv avatar Oct 08 '17 19:10 globalsysdesenv