0

If I start my application in airplane mode, I am expecting my delegate location manager object to have a fail since it should ben unreachable.

However, the method "locationManager:didUpdateLocations" gets called instead, and a location is given, but appears to have some internal objects to "nil".

enter image description here

The whole thing brings a consequent crash when the location object is passed and used. Shouldn't I receive a fixe error if the device is in airplane mode, with the method "locationManager:didFailWithError:" being invoked?

This doesn't happen if the app is already working.

dev_mush
  • 1,897
  • 2
  • 17
  • 32
  • What you need to do is check for connection availability before you call your CLLocationManager. http://stackoverflow.com/questions/1083701/how-to-check-for-an-active-internet-connection-on-iphone-sdk – Sam B Aug 13 '15 at 13:03

2 Answers2

2

FYI, in devices running iOS 8.3 or greater, GPS is not disabled when airplane mode is enabled.

rmp
  • 3,424
  • 1
  • 14
  • 25
1

Just for whoever will be asking the same question (that can be found elsewere here on stackoverflow asked in different ways), The CLLocationManager has an internal cache that expires after a bit. This means that if you go on Airplane mode and ask for a location, the location manager sends you the most recent it fixed UNTIL it clears the cache after a few minutes (almost 30), then it gives a location error.

Mi crash was because of something else, so the object returned works just fine.

If you want to be sure the fix has been done exactly when you asked for it, there's a "timestamp" property on a cllocation object that could be compared with [NSDate date] to understand if the returned location is "fresh" or cached.

dev_mush
  • 1,897
  • 2
  • 17
  • 32