iOS 7终止后重大位置更改启动
我的应用程序会在iOS 6上的新位置数据到达时自动唤醒,但不会在iOS 7上。
[[UIApplication sharedApplication] setBackgroundRefreshStatus]
是UIBackgroundRefreshStatusAvailable
。
在Info.plist
我设置了值为“location”的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 } }
有人知道问题在哪里吗?
它是7.0的iOSfunction,如果用户手动closures应用程序(从主页button双击),应用程序不会触发位置更改。
locationManager:didUpdateToLocation:fromLocation:
方法已被弃用,有效的iOS 6.您现在应该使用locationManager:didUpdateLocations: