iOS 7 Significant location change launch after termination

。_饼干妹妹 提交于 2019-12-24 08:49:04

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/19048526/ios-7-significant-location-change-launch-after-termination

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!