Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Geolocation crash if no data connection



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



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.

— asked August 12th 2010 by Michael Park
  • connection
  • data
  • geolocation
  • gps
  • location
  • provider
1 Comment
  • I've only been seeing this problem on the simulator, or when my phone is connected to my Mac so I can view the console. Other than that, I spent quite a lot of time trying to get the app to crash while on the subway(the tube over here in London) and there were no problems.

    — commented August 14th 2010 by Lukas Oberhuber

0 Answers

The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.