[英]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.