Geolocation crash if no data connection
UPDATE AT BOTTOM OF POST
Hi,
I've been successfully using the Geolocation module in my iPhone app for a while now, and have just gotten round to crash testing. I've hit a problem - when the device has no data connection (no wifi, no 3G connection) getting the location from the Geolocation module causes the app to crash.
The same happens on the 1.4 version of KitchenSink - try it with wifi turned off and 3G data disabled. It just crashes on me.
It appears that the Geolocation module is doing a call to a data service. I understand why it would do this for forward/reverse geocoding, but why would it do it for simple GPS calls?
Does anyone know a way of getting around this? I'd like to be able to get the device's location even when it doesn't have a data connection (ie. use the GPS alone).
The following code allows me to get around it by only using the Geolocation module if the device has a data connection, but this isn't really a solution.
if (Titanium.Network.online) {
Titanium.Geolocation.addEventListener('location',function(e) {
if (e.error) {
// error alert
return;
}
...
}
}
Thanks!
UPDATE
I've just had a look in the GeolocationModule.m file. The "didUpdateToLocation" method is creating a new Titanium Analytics Notification each time it fires - causing a crash if there's no data connection?. Disabling analytics is my tiapp.xml file stops this from firing and solves my problem. So, if you've come across this issue, disable analytics for now.