核心位置正常工作的超时时间

发布于 2024-10-20 11:12:14 字数 357 浏览 2 评论 0原文

我正在使用核心位置通过 iPhone 识别用户的位置。现在,当应用程序启动并且我进入 [locationManager startUpdatingLocation] 时,会显示一个警报框,其中包含文本“应用程序想要使用您当前的位置”。理想情况下,当用户在此警报框中按“确定”时,我希望启动超时 nstimer。显然没有办法捕获警报框响应,所以我所做的就是应用程序启动后立即启动计时器,超时时间为 10 秒。当然,这意味着如果用户没有及时按下警报框上的按钮,计时器就会超时,定位过程就会结束。超时计时器的原因是,即使在晴朗的天空下,应用程序有时也需要相当长的时间来识别用户的位置。

所以我想我要问的是,考虑到计时器和位置服务都在应用程序启动时启动,核心位置服务的理想超时时间应该是多少?

I'm using core location to identify the user's location via iphone. Now when the application starts and i go [locationManager startUpdatingLocation], an alertbox is shown with text "App would like to use your current location". Ideally I'd want to start a time out nstimer when the user presses OK on this alert box. Apparently there's no way to capture the alertbox response so what I do is start a timer as soon as the application starts with a timeout time of 10s. Of course this means that if the user does not press the buttons on the alertbox just in time, the timer will time out and that'll be the end of the location process right there. The reason for the time out timer is that at times the app takes rather longer time periods to identify the users location, even under a clear sky.

So i guess what I'm asking is what should be the ideal time out period for the core location services given that the timer and the location service both start when the application starts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

将军与妓 2024-10-27 11:12:14

在这里很难给出一般性建议,因为这实际上取决于您想要的数据的准确性和新鲜度。通常,您会收到多个不同年龄和准确性的核心位置更新。通常,您会首先收到旧的缓存位置。然后您将收到基于 WiFi 和手机信号塔三角测量的更新。 GPS 更新需要的时间最长,并且取决于晴朗的天空。因此,如果您对手机信号塔精度(约 3 公里)的缓存位置更新感到满意,那么您通常不必等待很长时间。 20秒的暂停应该是绝对没问题的。当然,如果您想涵盖“无运营商”的情况,情况会有所不同,因此取决于 GPS。

It's hard to give a general advice here because it really depends on what accuracy and freshness of the data you want. Generally, you'll receive multiple Core Location updates of different age and accuracy. Normally, you'll receive an old, cached location first. Then you'll receive updates based on WiFi and cell tower triangulation. GPS updates takes the longest time and are dependent on clear sky. So if you're fine with a cached location update with cell tower accuracy (~3 km), then you normally don't have to wait for a long time. A 20 second time out should be absolutely fine. Of course, things are different if you wanna cover the "No Carrier" case and thus are dependent on GPS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文