deferredLocationUpdatesAvailable returns iOS 10 中没有
deferredLocationUpdatesAvailable returns NO in iOS 10
我正在尝试使用一些 CoreLocation 功能,但我 运行 遇到了延迟位置更新的问题。
出于某种原因,当应用程序更新为 iOS 10 deferredLocationUpdatesAvailable returns NO 总是。我正在 iPhone 6s 上进行测试,因此我知道该设备能够使用 GPS 功能。
我试过用这个调试:
[CLLocationManager deferredLocationUpdatesAvailable]
我不知道这是 iOS 10 的问题还是我设置不正确。
在这个方法中:
- (void)locationManager:(CLLocationManager *)manager didFinishDeferredUpdatesWithError:(NSError *)error {
self.deferringUpdates = NO;
NSLog(@"DEFERRING Error: [%@]", error);
if (error) {
[[LocationManagerClient alertWithMessage:error.localizedDescription andTitle:error.domain] show];
}
}
我最终记录了这个错误:
DEFERRING Error: [Error Domain=kCLErrorDomain Code=11 "(null)"]
有其他人 运行 遇到过 iOS 10 的这个问题,或者知道发生了什么事吗?
编辑:
这就是我设置距离过滤器的方式
- (void)configureForApplicationWillResignActive {
[_locationManager setAllowsBackgroundLocationUpdates:YES];
[_locationManager setPausesLocationUpdatesAutomatically:NO];
[_locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[_locationManager setDistanceFilter:kCLDistanceFilterNone]; // use distance filter
[_locationManager requestAlwaysAuthorization];
}
- (void)configureForApplicationDidBecomeActive {
[_locationManager setAllowsBackgroundLocationUpdates:YES];
[_locationManager setPausesLocationUpdatesAutomatically:NO];
[_locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[_locationManager setDistanceFilter:kCLDistanceFilterNone]; // use distance filter
[_locationManager requestAlwaysAuthorization];
}
我看起来这是 iOS 10
中的错误
我们应该全部归档雷达以修复它,请欺骗我的:openradar.appspot.com/radar?id=4927958787555328
我已经提交了带有概念证明的 Radar (28303779) sample code - also contains the wording from the radar. I have also opened a dev forum post,看来很多工程师都面临着同样的问题。 deferredLocationUpdatesAvailable()
也在 iOS 10 中返回 false。似乎苹果有意关闭了该功能。
更新
我的错误报告已关闭,显示 'it works as intended'。我想 Apple 并不打算修复它,而是在没有先弃用的情况下被错误地删除了。
好像是"bug"。 (转载于 iOS11 和 iOS12、iPhone 7、iPad mini 4 cellular)
CLLocationManager.deferredLocationUpdatesAvailable() 始终 returns false,因此延迟更新的代码永远不会 运行。然而,当应用程序在后台并且位置管理器通过 locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) 传递位置时,这些位置被延迟,就像启用了延迟模式一样。
我认为deferred API只是为了兼容旧应用,新应用根本不需要担心它。
延迟更新现已正式弃用(在 iOS 13 中)。这实际上是承认他们多年来一直没有得到支持。
我正在尝试使用一些 CoreLocation 功能,但我 运行 遇到了延迟位置更新的问题。
出于某种原因,当应用程序更新为 iOS 10 deferredLocationUpdatesAvailable returns NO 总是。我正在 iPhone 6s 上进行测试,因此我知道该设备能够使用 GPS 功能。
我试过用这个调试:
[CLLocationManager deferredLocationUpdatesAvailable]
我不知道这是 iOS 10 的问题还是我设置不正确。
在这个方法中:
- (void)locationManager:(CLLocationManager *)manager didFinishDeferredUpdatesWithError:(NSError *)error {
self.deferringUpdates = NO;
NSLog(@"DEFERRING Error: [%@]", error);
if (error) {
[[LocationManagerClient alertWithMessage:error.localizedDescription andTitle:error.domain] show];
}
}
我最终记录了这个错误:
DEFERRING Error: [Error Domain=kCLErrorDomain Code=11 "(null)"]
有其他人 运行 遇到过 iOS 10 的这个问题,或者知道发生了什么事吗?
编辑: 这就是我设置距离过滤器的方式
- (void)configureForApplicationWillResignActive {
[_locationManager setAllowsBackgroundLocationUpdates:YES];
[_locationManager setPausesLocationUpdatesAutomatically:NO];
[_locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[_locationManager setDistanceFilter:kCLDistanceFilterNone]; // use distance filter
[_locationManager requestAlwaysAuthorization];
}
- (void)configureForApplicationDidBecomeActive {
[_locationManager setAllowsBackgroundLocationUpdates:YES];
[_locationManager setPausesLocationUpdatesAutomatically:NO];
[_locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[_locationManager setDistanceFilter:kCLDistanceFilterNone]; // use distance filter
[_locationManager requestAlwaysAuthorization];
}
我看起来这是 iOS 10
中的错误我们应该全部归档雷达以修复它,请欺骗我的:openradar.appspot.com/radar?id=4927958787555328
我已经提交了带有概念证明的 Radar (28303779) sample code - also contains the wording from the radar. I have also opened a dev forum post,看来很多工程师都面临着同样的问题。 deferredLocationUpdatesAvailable()
也在 iOS 10 中返回 false。似乎苹果有意关闭了该功能。
更新
我的错误报告已关闭,显示 'it works as intended'。我想 Apple 并不打算修复它,而是在没有先弃用的情况下被错误地删除了。
好像是"bug"。 (转载于 iOS11 和 iOS12、iPhone 7、iPad mini 4 cellular)
CLLocationManager.deferredLocationUpdatesAvailable() 始终 returns false,因此延迟更新的代码永远不会 运行。然而,当应用程序在后台并且位置管理器通过 locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) 传递位置时,这些位置被延迟,就像启用了延迟模式一样。
我认为deferred API只是为了兼容旧应用,新应用根本不需要担心它。
延迟更新现已正式弃用(在 iOS 13 中)。这实际上是承认他们多年来一直没有得到支持。