I make a location app. But Core Location does not work.
I tested other iPhone application on my iPhone.
Like google earth, a navigation software.
The other applications do not work also.
Why doesn't update location?
Why 'locationManager:didUpdateToLocation:fromLocation:' message called 2 times only?
Maybe... My iPhone broken down? or iOS 6 CoreLocation frameworks have some bug?
Location service - On on iPhone settings
Info.plist
- armv7
- accelerometer
- location-services
- gps
- microphone
- magnetometer
Code Example:
- (CLLocationManager *)setupLocationManager
{
if ([CLLocationManager locationServicesEnabled] && [CLLocationManager headingAvailable]) {
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.headingFilter = kCLHeadingFilterNone;
[locationManager startUpdatingLocation];
[locationManager startUpdatingHeading];
return locationManager;
}
return nil;
}
- (CLLocationManager *)locationManager
{
switch([CLLocationManager authorizationStatus])
{
case kCLAuthorizationStatusAuthorized:
_deltaTimeLocationReceived = 0.0;
if (_locationManager == nil)
_locationManager = [self setupLocationManager];
return _locationManager;
case kCLAuthorizationStatusDenied:
case kCLAuthorizationStatusRestricted:
if (_locationManager)
_locationManager = nil;
return _locationManager;
case kCLAuthorizationStatusNotDetermined:
_deltaTimeLocationReceived = 0.0;
if (_locationManager == nil)
_locationManager = [self setupLocationManager];
return nil;
}
return nil;
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"%@ %@", NSStringFromSelector(_cmd), newLocation.description);
if (self.locationManager) _locationSignal++;
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"%@ %@", NSStringFromSelector(_cmd), error.description);
}
In iOS 6 Apple has made breaking changes to Core Location by implementing the AutoPause API. The AutoPause API pauses the location updates when an application goes into the background and applies to a couple of criteria (i.e. user not moving, no location fix, user discontinues activity). To accurately handle pause events Apple requests to help better predicting whether or not to pause location updates setting an activity type (i.e. navigation, fitness, other). The AutoPause API is enabled by default when an application is compiled against iOS 6.
The easy fix is to disable the AutoPause API for now by always setting 'pausesLocationUpdatesAutomatically' to NO. Location updates will be send even when the app goes in the background, like it used to work in < iOS 6.
More details here:
http://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html
Do you have any message from delegate method ?
If no message, check interface description of you class.
@interface ... <... CLLocationManagerDelegate ...>
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
delegate doesnt exist in ios 6 anymore.Instead use
Check Apple documentation for startUpdateLocation
This code (and the pausesLocationUpdatesAutomatically) would compile only in XCode 4.5 (where the base SDK is 6).
If you want to target iOS versions prior to 6.0 then use this macro
and wherever you are creating the CLLocationManager object
The locationManager delegate should work in all version when compiled from Xcode 4.5