3

Even my app is register for Location updates in background.

In my code:

self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
self.locationManager.distanceFilter = 2500;

And I not moved anywhere. So after exactly 15 minutes in console log I got this message "Location icon should now be in state 'Inactive'" . From this point onwards my app is not running in background.

It's happening in iPhone 5 only.

@updated

Here is my code

self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
[self.locationManager setPurpose:@"Enable Location service for \"My App\" to track your"];
self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;

/* Notify changes when device has moved x meters.
 * Default value is kCLDistanceFilterNone: all movements are reported.
 */
self.locationManager.distanceFilter = 2500;
[self.locationManager startUpdatingLocation];
Bhumeshwer katre
  • 4,671
  • 2
  • 19
  • 29

2 Answers2

5

Was your app in the background when location service become inactive?

If you don't want to pause location update in background than you need to set pausesLocationUpdatesAutomatically flag,

if ([self.locationManager respondsToSelector:@selector(pausesLocationUpdatesAutomatically)]) {
    self.locationManager.pausesLocationUpdatesAutomatically = NO;
}
Adi Inbar
  • 12,097
  • 13
  • 56
  • 69
Vishwa Patel
  • 484
  • 2
  • 10
2

Since iOS 6 Apple has added @property(assign, nonatomic) BOOL pausesLocationUpdatesAutomatically to CLLocationManager. Default value is YES. Change value of this property to NO and the location tracking will not stop in the background.

Sviatoslav Yakymiv
  • 7,887
  • 2
  • 23
  • 43