应用程序终止/暂停时的后台用户位置 [英] Background user location when app is terminated/suspended

查看:134
本文介绍了应用程序终止/暂停时的后台用户位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图弄清楚如何在应用程序终止时获取用户的位置,就像应用程序Moves一样。我知道这样做的唯一方法是使用重要的位置更改。但是,如果位置发生重大变化,应用程序每隔500米就会被唤醒,并且只有在最后一次更新后大约5分钟才会被唤醒。

I've been trying to figure out how to get the user's location when the app is terminated like how the app Moves does it. The only way I know of doing so is with Significant Location Changes. However with significant location changes, the app only gets woken up either every 500 meters and only if it has been around 5 minutes past the last update.

根据Apple的说法:

According to Apple:


应用程序可以立即收到通知设备从之前的通知移动500米或更长时间。它不应该比每五分钟更频繁地预期通知。如果设备能够从网络中检索数据,则位置管理员更有可能及时发送通知。

Apps can expect a notification as soon as the device moves 500 meters or more from its previous notification. It should not expect notifications more frequently than once every five minutes. If the device is able to retrieve data from the network, the location manager is much more likely to deliver notifications in a timely manner.

在Moves应用程序中,即使应用程序终止,它也能够非常准确地检索用户的位置,而不会在电池中排出太多水。它似乎也没有打开背景位置,因为电池使用列表中的原因仅显示背景活动。所以我想知道像Move这样的应用程序是如何做到这一点的。任何帮助都会很棒!谢谢。

In the Moves app, even with the app is terminated, it is able to retrieve the user's location very accurately without having much drainage in battery. It also doesn't seem to have background location turned on as it's reason in the battery usage list only shows "Background Activity". So I'm wondering how an app like Moves is doing this. Any help would be great! Thanks.

推荐答案

您可以注册500米区域内的区域并在其中注册通知区域通知。当它达到一个时,你的应用程序将在后台启动。然后,重新注册新的位置,将该位置保持在中心位置。

You can register for regions in 500m area and register for notification region notification in them. When it reaches one if them, your app is launched in background. Then, re-register for new ones keeping that location at center.

来自 Apple的文档


支持后台执行的应用程序可能由系统重新启动以处理传入的事件。如果某个应用因用户强行退出而导致其终止,系统会在发生以下任一事件时启动该应用:

Apps that support background execution may be relaunched by the system to handle incoming events. If an app is terminated for any reason other than the user force quitting it, the system launches the app when one of the following events happens:

对于位置应用:


  • 系统会收到符合应用程序配置的交付条件的位置更新。

  • The system receives a location update that meets the app’s configured criteria for delivery.

设备进入或退出注册区域。 (区域可以是地理区域或iBeacon区域。)

The device entered or exited a registered region. (Regions can be geographic regions or iBeacon regions.)

这篇关于应用程序终止/暂停时的后台用户位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆