当飞行模式打开时 CLLocationManager 如何获取位置
我的应用程序使用 CLLocationManager 从设备获取位置更新。
我曾假设当设备处于飞行模式时,我不会获得位置更新。但我愿意。
我之所以这么认为,是因为 Apple 表示飞行模式会关闭 Wifi、蜂窝网络、蓝牙和 GPS。请参阅:http://support.apple.com/kb/ht1355
那么,这是怎么回事?我收到的位置更新的坐标似乎合理?
My app uses CLLocationManager to get location updates from the device.
I had assumed that when the device was in Airplane Mode, I would not get location updates. But I do.
The reason I assumed this is because Apple says that Airplane mode turns off Wifi, Cellular, Bluetooth, and GPS. See: http://support.apple.com/kb/ht1355
So, how is it that I'm getting a location update with a coordinate that seems reasonable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我开发了一个大量使用用户位置的应用程序,因此我必须检查这种情况和其他情况。
我了解到,当所有服务都关闭时(蓝牙、Wi-Fi、蜂窝数据)
CLLocationManager 返回最新的已知位置,因此,在这种情况下,即使设备处于飞行模式,它也会返回一个位置。
您可以通过获取您的位置来尝试此操作,打开飞行模式,然后远离那里,再次询问位置。
TL; DR: 事实并非如此。它返回最新的已知位置。
I've developed an app that heavily uses the user location, so I had to check this and other situations.
I've learned that when all the services are off (Bluetooth, Wi-Fi, Cell Data)
CLLocationManager returns the latest known location, so, in this case, even if the device in Airplane mode it will return a location.
You can try this by getting your location, turn Airplane mode on and then go far from there, ask the location again.
TL; DR: It doesn't. It returns the latest known location.
您可以在飞行模式下手动重新打开 WiFi,并且如果您等待足够长的时间,可能会获得 GPS 修复,具体取决于 iDevice 型号。
You can manually turn WiFi back on in Airplane Mode, and possibly get a GPS fix if you wait long enough, depending on the iDevice model.