当新的位置数据到达 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
}
}
有谁知道哪里出了问题?