简体   繁体   English

终止后启动iOS 7重大位置更改

[英]iOS 7 Significant location change launch after termination

My app automatically wakes up after termination when new location data arrives on iOS 6, but not on iOS 7. 当新的位置数据到达iOS 6而非iOS 7时,我的应用终止后会自动唤醒。

[[UIApplication sharedApplication] setBackgroundRefreshStatus] is UIBackgroundRefreshStatusAvailable . [[UIApplication sharedApplication] setBackgroundRefreshStatus]UIBackgroundRefreshStatusAvailable

In Info.plist I set UIBackgroundModes with value "location". Info.plist我将UIBackgroundModes设置为值“ location”。

CLLocationManager started this way: CLLocationManager以这种方式启动:

- (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? 有人知道哪里有问题吗?

这是7.0 iOS功能,如果用户手动关闭应用程序(通过主页按钮双击),则该应用程序不会在位置更改时触发。

不建议使用locationManager:didUpdateToLocation:fromLocation:方法,从iOS 6开始生效。您现在应该使用locationManager:didUpdateLocations:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM