Cordova-plugin-googlemaps: Can the "Location Services not Available" prompt be disabled for ios?

Created on 17 Jul 2018  路  9Comments  路  Source: mapsplugin/cordova-plugin-googlemaps

I'm submitting a ... (check one with "x")

  • [X] question
  • [ ] any problem or bug report
  • [ ] feature request

If you choose 'problem or bug report', please select OS: (check one with "x")

  • [ ] Android
  • [X] iOS

Whenever I call map.getMyLocation() on ios (and I have location services turned off) a popup window comes up telling me to go to settings and enable them. As I would like to control what happens in the flow of my app if location services are not enabled, is there a way to disable that popup?

fixed

All 9 comments

This plugin does not show up any popup.

Map.getMyLocation() is an alias of LocationService.getMyLocation().
https://github.com/mapsplugin/cordova-plugin-googlemaps/blob/master/www/LocationService.js
https://github.com/mapsplugin/cordova-plugin-googlemaps/blob/master/src/ios/GoogleMaps/PluginLocationService.m

Can you find any alert() dialog, or any popup command in the source code?

The message in the dialog is the one found here:

https://github.com/mapsplugin/cordova-plugin-googlemaps/blob/master/src/ios/strings/pgm_Localizable_en.json

"LOCATION_IS_UNAVAILABLE_ERROR_TITLE" : "Location Service is not available",
  "LOCATION_IS_UNAVAILABLE_ERROR_MESSAGE" : "This app needs to access your location. Please turn on \"Settings > Privacy > Location Services\"",

And yes I can find the the alert in PluginLocationService.m

NSString *LOCATION_IS_UNAVAILABLE_ERROR_MESSAGE = [PluginUtil PGM_LOCALIZATION:@"LOCATION_IS_UNAVAILABLE_ERROR_MESSAGE"];
        UIAlertController* alert = [UIAlertController alertControllerWithTitle:LOCATION_IS_UNAVAILABLE_ERROR_TITLE
                                                                       message:LOCATION_IS_UNAVAILABLE_ERROR_MESSAGE
                                                                preferredStyle:UIAlertControllerStyleAlert];

Ah, I see. I forgot it.
However, the alert dialog is useful for most people.

Well, please use other geolocation plugin, such as cordova-geolocation-plugin

That's what I ended up opting for, but in the spirit of trying to lighten the load of the app (more plugins = more load time), may I suggest in a future version of maps plugin that you can pass an additional key in the LocationOptions, (maybe showUnavailablePrompt: true/false) and let the developer decide if they want to use this feature.

I would fork and create a pull request for it, but I'm afraid I don't know how to code for ios

How about creating a new method, such as LocationService.hasPermission()?

That would be even better. Can this work both for ios and android?

Done

Wow that was fast!!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wf9a5m75 picture wf9a5m75  路  5Comments

melkir picture melkir  路  5Comments

ebellempire picture ebellempire  路  3Comments

christoph-puppe picture christoph-puppe  路  5Comments

nakulkundaliya picture nakulkundaliya  路  5Comments