我正在尝试使用新的 iOS 6 延迟位置更新功能,但不断收到此错误:
didFinishDeferredUpdatesWithError :Error Domain=kCLErrorDomain Code=11 “操作无法完成。(kCLErrorDomain 错误 11。)”
我正在使用以下代码:
- (DeviceAPI *) init
{
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager startUpdatingLocation];
[locationManager allowDeferredLocationUpdatesUntilTraveled:(CLLocationDistance)100000 timeout:(NSTimeInterval)100000];
return self;
}
和这个callback
功能 :
- (void)locationManager: (CLLocationManager *) manager
didFinishDeferredUpdatesWithError:(NSError *)error
{
NSLog(@"didFinishDeferredUpdatesWithError :%@", [error description]);
}
有什么帮助吗?
根据 iOS 6.0 SDK 的 Apple 开发者论坛,延迟位置更新仅适用于:
- 在 iPhone 5 硬件上
- 运行 iOS 6.0 或更高版本
- 所需的精度设置为
kCLLocationAccuracyBest
or kCLLocationAccuracyBestForNavigation
因为这requiresGPS芯片。没有蜂窝数据的 iPad 没有 GPS 芯片。
- 调用“startUpdatingLocation”方法
- 等待大约每秒 1 次的位置更新
- 然后开始推迟更新
See: https://devforums.apple.com/message/751974#751974 https://devforums.apple.com/message/751974#751974
请参阅文档:allowDeferredLocationUpdates(untilTraveled:timeout:)
https://developer.apple.com/documentation/corelocation/cllocationmanager/1620547-allowdeferredlocationupdates
听起来您需要 iPhone 5 硬件,并等待位置更新以 1Hz 的速度进行。
此外,正如另一位海报提到的,您需要实施locationManager:didUpdateLocations:
方法在你的委托中。
最常见的地方称之为 [allowDeferredLocationUpdates
] 方法在你的委托中locationManager(_:didUpdateLocations:)
方法。处理完任何
新位置,如果您想推迟将来的更新,请调用此方法
直到满足距离或时间标准。如果有新事件到来并且
您的应用程序在后台,事件被缓存并且它们
交货期适当推迟。
From docs https://developer.apple.com/documentation/corelocation/cllocationmanager/1620547-allowdeferredlocationupdates. I've added notes inside []
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)