An application is being developed that should receive the latest location from the CLLocationManager (without any regular tracking). No matter how old, accurate. I don’t need and you want to start tracking - I just need to take the last place from the cache and it. IMHO, CLLocationManager is a common component in iOS, and if some application uses location tracking, another application should be able to use the last location from CLLocationManager.location. Just select / init CLLocationManager and capture its location. However, it is not. I tested on iPhone4 - I started working with Google maps, saw my current location, and then went to my application, but after the [[CLLocationManager alloc] init] property was zero.
UPDATE: tried [locationManager startUpdatingLocation]; and [locationManager stopUpdatingLocation]; but the result is the same. I think the only solution is to start regular tracking?
UPDATE2: Strange, but no warning with “Application wants to use location services” after alloc / init CLLocationManager. Here is my code snippet:
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
[locationManager startUpdatingLocation];
[locationManager stopUpdatingLocation];
NSLog(@"%@", locationManager.location);
source
share