didFinishDeferredUpdatesWithError :Error Domain=kCLErrorDomain Code=11 “The operation couldn’t be completed. (kCLErrorDomain error 11.)”
我使用以下代码:
- (DeviceAPI *) init { locationManager = [[CLLocationManager alloc] init]; [locationManager setDelegate:self]; [locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; [locationManager startUpdatingLocation]; [locationManager allowDeferredLocationUpdatesUntilTraveled:(CLLocationDistance)100000 timeout:(NSTimeInterval)100000]; return self; }
而这个回调函数:
- (void)locationManager: (CLLocationManager *) manager didFinishDeferredUpdatesWithError:(NSError *)error { NSLog(@"didFinishDeferredUpdatesWithError :%@",[error description]); }
有帮助吗?
解决方法
>在iPhone 5硬件上
>运行iOS 6.0或更高版本
>所需精度设置为kCLLocationAccuracyBest或kCLLocationAccuracyBestForNavigation,因为这需要GPS芯片.没有手机数据的iPad没有GPS芯片.
>调用“startUpdatingLocation”方法
>等待位置更新以大约每秒1进入
>然后开始推迟更新
见:https://devforums.apple.com/message/751974#751974
见文档:allowDeferredLocationUpdates(untilTraveled:timeout:)
所以听起来你需要iPhone 5硬件,等待位置更新以1Hz的速度进入.
另外,正如另一张海报所提到的,您需要在委托中实现locationManager:didUpdateLocations:方法.
The most common place to call this [
allowDeferredLocationUpdates
] method is in your delegate’slocationManager(_:didUpdateLocations:)
method. After processing any
new locations,call this method if you want to defer future updates
until the distance or time criteria are met. If new events arrive and
your app is in the background,the events are cached and their
delivery is deferred appropriately.From 07002. I’ve added notes inside
[]
.