【发布时间】:2013-09-27 10:28:37
【问题描述】:
当新的位置数据到达 iOS 6 时,我的应用程序会在终止后自动唤醒,但在 iOS 7 上不会。
[[UIApplication sharedApplication] setBackgroundRefreshStatus] 是UIBackgroundRefreshStatusAvailable。
在Info.plist 中,我将UIBackgroundModes 设置为值“位置”。
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
}
}
有人知道问题出在哪里吗?
【问题讨论】:
-
顺便说一句,我认为您不需要后台模式设置for significant change service。这只是标准位置服务所需要的。
-
我也有同样的问题,你有什么解决办法吗??
-
这是 iOS 7 的功能。 stackoverflow.com/questions/18212171/…