如何使用 nstimer 为位置管理器设置后台?

发布于 2025-01-06 10:33:53 字数 161 浏览 3 评论 0原文

我的 ios sdk 有问题。 我需要设置一个计时器,每隔 xx 分钟在后台更新一次手机的位置。 当位置精度达到10米时,应该用我准备好的方法将其保存到本地数据库。 我该怎么办?如何保存电池?有人有一些示例代码来执行此操作吗?

可以使用视图中的按钮启动和停止计时器。

感谢大家

I have a problem with ios sdk.
I need to set a timer that I update the phone's location every xx minutes in the background.
When the position has an accuracy of 10 meters should be saved to a local db with a method that I have ready.
How can I do? How can I preserve the battery? Does anyone have some sample code to do this?

The timer can be started and stopped with a button in a view.

Thanks to all

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

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

发布评论

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

评论(1

纵性 2025-01-13 10:33:53

不幸的是,当您的应用程序处于后台状态时,NSTimer 会暂停。您需要使用 startMonitoringSignificantLocationChanges 或 startUpdatingLocation 来获取后台状态下的用户位置。

Unfortunately, NSTimer is paused when your app is in background state. You need to use startMonitoringSignificantLocationChanges or startUpdatingLocation to get user's location in background state.

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