I am running into a very strange situation with an app I have that uses CLLocationManager to get the user's current location. I am using a wrapper class that is very similar to Apple's CLLocationManager example code. It starts looking for location, and it waits until it is given a location that meets some criteria (timestamp age, accuracy). All works well when I am in a very GPS-accessible area.

Now the issue. When I am in my office, on a WiFi connection, where the GPS signal is seemingly lousy, I open my app and it can never find a suitable location. I exit out of my app, open Foursquare, and it finds places near me almost immediately, leading me to assume that it has found my location. I exit Foursquare, and reopen my app to find that it finds my location almost instantly.

Can anyone shed some light on what might be happening here? I can post some code if folks think that would be helpful, but this is more a general question about how other apps can positively or negatively affect the functionality of CLLocationManager. Ideally, I'd love to know what exactly Foursquare is doing to get a location so quickly, and how that might cause my app to suddenly start getting one as well.

EDIT: It seems like based on the answer below, people have experienced cross-app cacheing, which is fine. However, it doesn't explain why Foursquare gets a location and my app only gets it after using Foursquare. Below is my CLLocationManager code, hopefully someone can find some smoking gun:

Many of us would like to know the same thing.....
–
KevinDTimmJan 20 '12 at 15:36

In terms of cacheing, or in terms of how Foursquare is gathering location coordinates?
–
nickbonaJan 20 '12 at 16:33

I have seen some interesting behavior re:Location gathering at startup that does not jibe with (for example) google maps. Whereas they (seem to) get info right away, my app doesn't seem to get location updates as expeditiously. Running maps (for example) before my app improves the performance of my app :( This does not seem right.
–
KevinDTimmJan 20 '12 at 17:06

2 Answers
2

and not kCLLocationAccuracyBest? Of course, without comparing the horizontal accuracy with this, as you noticed yourself, negative constant - but some reasonable other value (say 100.0m) instead. Have you tried whether it makes a difference?

The desired accuracy controls how much effort is put into the position acquisition (for the higher values, GPS is not even turned on, as you can check with Xcode/Instruments/EnergyDiagnostics). Less effort results in both less accuracy and/or more time to get a position. Doesn't that sound reasonable?

From my own observations: When asking iOS for a position with a certain desired precision, the result can be anything: Less accurate (i.e. in a building with poor GPS reception), as accurate as desired, or in fact more accurate than needed (another application or another CLlocationManager object of the same application might simultaneously ask the hardware for a higher accuracy - then all other applications inherit the better values without additional effort).

In addition to the above, it might make a difference whether you iOS device is accessing the internet, because it is an assisted GPS receiver. Maybe there is some kind of side effect with some assisting data being downloaded, if the device happens to be online because of some other internet activity. This last thought is pure speculation, though.

One more thing:
If I haven't overlooked it in your code, then you have not defined a distance filter. Try something like

yes, I think CLLocationManager cache the location to some extend, I tried a few stuff, like running GoogleMaps, my location was found, then ran my app, it found my location immediately. Also tried, running a navigation app, found my location, immediately kill it, run other apps that use location, all the apps can find the lock in the location almost instantaneously.