Use and then turn off Geolocation services
iOS / Titanium 1.4.1.1
I have an app with the following:
Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_BEST;
Ti.Geolocation.distanceFilter = 200;
Ti.Geolocation.getCurrentPosition(function(e) {
Ti.Geolocation.addEventListener('location', locationListener);
});
and a map somewhere…
mapView = Ti.Map.createView({
mapType: Ti.Map.STANDARD_TYPE,
userLocation:true,
animate:true
});
and then finally, when the map is no longer needed, there is:
Ti.Geolocation.removeEventListener('location', locationListener);
mapView.hide();
Here's what I've observed…
- Once the location is used, iOS shows the purple location services indicator
- Even though the map is no longer displayed (I tried to remove it but get a crash), and I think the geoLocation eventListener has been removed, location services stays active
- If I switch to another app under iOS 4 multitasking, location services icon goes away; switching back usually turns it on, but not all the time; if it is off then I can navigate to the map tab and it goes on
Is there a way to stop requesting location services?
1 Answer
-
Accepted Answer
The Objective-C that is created for the project (GeolocationModule.m around line 369) does have code to turn off location services if you remove all the listeners. From the looks of it you need to make sure the reference counts drop to 0 for both location and heading listeners or the location services will remain on.