hansemannn / titanium-googlemaps

🗺 Use the Google Maps SDK in Titanium
Other
87 stars 26 forks source link

iOS asks for location permission #76

Closed andersdp closed 7 years ago

andersdp commented 7 years ago

I don't think this is related to this (excellent) module but it seems like a good place to ask.

We have an app that relies heavily on an location. Either the current or one provided by the user. Recently we moved from users entering an address manually (if they didn't give access to location) to letting them pick out a location via map.

To the question: When users open a map for the first time is it not possible to avoid the question about giving access to location? We feed some coordinates into the map when opening and just want to give users the option of panning around to select a location.

skaermbillede 2017-02-10 kl 11 18 04
andersdp commented 7 years ago

Basically I just want our users to be able to navigate a map without being asked about access to gps location. We don't need their current location.

hansemannn commented 7 years ago

Thanks for the feedback! I'll check the issue, but does it help to manually disable the myLocationEnabled property on the map view?

andersdp commented 7 years ago

We have myLocationEnabled=false and it still asks for access.

But we're unsure of whether or not iOS is supposed to work like that?

This is the properties we use:

mapType: Map.MAP_TYPE_NORMAL,
zoomGestures: true,
indoorEnabled: false,
indoorPicker: false,
compassButton: false,
myLocationButton: false,
myLocationEnabled: false,
scrollGesture: false,
tiltGestures: false,
rotateGestures: false,
region:{
latitude:_lat,
longitude:_lng,
zoom: _zoom
}
yozef commented 7 years ago

Check the tiapp.xml if you're using: key>NSLocationUsageDescription</key> or <key>NSLocationWhenInUseUsageDescription</key> However, to my recollection, these don't ask for permission automatically.

On another note, maybe you have Ti.Geolocation.addEventlistener somewhere?

andersdp commented 7 years ago

We use NSLocationWhenInUseUsageDescription

hansemannn commented 7 years ago

Just checked a quick example, it doesn't ask me for permissions as well:

var maps = require('ti.googlemaps');
maps.setAPIKey('<api-key>');

var win = Ti.UI.createWindow({
    backgroundColor: '#f00'
});

var mapView = maps.createView({
    region: {
        latitude: 37.368122,
        longitude: -121.913653,
    }
});
win.add(mapView);
win.open();
hansemannn commented 7 years ago

And as @yozef said, every Ti.Geolocation usage would also trigger the dialog. Side note: If you remove the module usage, does it still prompt then?

andersdp commented 7 years ago

Okay, seems like I need to run through our code and make sure we don't do something that triggers it.

@hansemannn Just to be sure; It was a fresh install you did so the permission wasn't already set?

hansemannn commented 7 years ago

Yes. I uninstalled the app completely of course :-). Closing this issue for now, please let me know if it should be reopened when you can isolate it to the module. Thx!

yozef commented 7 years ago

@andersdp Do a quick Search on the project for Ti.Geolocation or Titanium.Geolocation

andersdp commented 7 years ago

Ok will run through our code - thanks for your time guys 👍🏼

jonasfunk commented 7 years ago

Working on the same project as @andersdp, I was looking into this issue, and appearantly the app prompts for gps permission if you have the NSLocationWhenInUseUsageDescription in tiapp.xml. Just creating the object like this:mapview = Map.createView({}); will trigger the prompt.

hansemannn commented 7 years ago

Thanks @jonasfunk, but then it's definitely the Google Maps iOS SDK causing the issue. I can try doing the same natively, but I'm pretty sure it behaves the same.

jonasfunk commented 7 years ago

Would be nice to know, if it the outcome is the same natively. Seems strange that you're not able to generate a map without prompting the user for GPS access.

hansemannn commented 7 years ago

Checked it! It's indeed our bug - the "myLocationEnabled" property was enabled by default. Justed changed it, commit and new version coming later today. Thanks guys!

yozef commented 7 years ago

Hi @hansemannn is this what you are referring to, or is being set somewhere else?

- (void)setMyLocationEnabled:(id)value
{
    ENSURE_UI_THREAD_1_ARG(value);
    ENSURE_TYPE(value, NSNumber);

    [[[self mapView] mapView] setMyLocationEnabled:[TiUtils boolValue:value]];
    [self replaceValue:value forKey:@"myLocationEnabled" notification:NO];
}

Update: Ok, I see what you mean, it's here: https://github.com/hansemannn/ti.googlemaps/blob/master/ios/Classes/TiGooglemapsView.m

[_mapView setMyLocationEnabled:[TiUtils boolValue:[self.proxy valueForKey:@"myLocationEnabled"] def:YES]];
hansemannn commented 7 years ago

Fixed as part of https://github.com/hansemannn/ti.googlemaps/commit/8ec1f2eb0b573c80a0d863253d81ebaf7ec60997. @yozef The related bug was here and remained from early tests when i created the first draft of this module. In addition, the interactionEnabled wasn't even used (part of UIKit, not of the module), so I cleaned that up as well.