1

My app automatically wakes up after termination when new location data arrives on iOS 6, but not on iOS 7.

[[UIApplication sharedApplication] setBackgroundRefreshStatus] is UIBackgroundRefreshStatusAvailable.

In Info.plist I set UIBackgroundModes with value "location".

CLLocationManager started this way:

- (void) start {
  if (locationManaher == nil) {
    locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate        = self;
    locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
  }

  [locationManager startMonitoringSignificantLocationChanges]
}

- (void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {

  CLLocationCoordinate2D newCoordinate = newLocation.coordinate;
  CLLocationCoordinate2D oldCoordinate = oldLocation.coordinate;

  if (newCoordinate.latitude == oldCoordinate.latitude && newCoordinate.longitude == oldCoordinate.longitude) return;

  float distance = [newLocation distanceFromLocation:oldLocation];

  if (distance < distanceFilter) {
    //send to server 
  }
}

Does anybody know where is a problem?

Richard Sitze
  • 8,262
  • 3
  • 36
  • 48
Artem
  • 128
  • 5
  • BTW, I don't believe you need that background mode setting [for significant change service](https://developer.apple.com/library/ios/documentation/general/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW22). That's only needed for standard location services. – Rob Sep 27 '13 at 12:05
  • Possible dublicated http://stackoverflow.com/questions/18946881/background-location-services-not-working-in-ios-7 – Igor Nov 08 '13 at 12:22
  • I have same problem, Do you have any solution ?? –  Nov 22 '13 at 12:18
  • It's iOS 7 feature. http://stackoverflow.com/questions/18212171/application-doesnt-launch-with-location-key-after-a-significant-location-change – Artem Nov 23 '13 at 08:32

2 Answers2

4

It is 7.0 iOS feature, if user closes the app manually (from home button double click), the application doesn't triggers on location change.

Tatiana
  • 390
  • 8
  • 23
  • I couldn't see any kinds of information in Location programming guide. Could you please provide a link for it? – kkocabiyik Jan 04 '14 at 12:46
1

The locationManager:didUpdateToLocation:fromLocation: method is deprecated, effective iOS 6. You should use now locationManager:didUpdateLocations:.

Rob
  • 415,655
  • 72
  • 787
  • 1,044
  • In my code I use both methods: 1. - (void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations 2. - (void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation – Artem Sep 27 '13 at 13:15