如何在应用程序被终止后继续进行 iOS 位置跟踪?

How continue doing iOS location tracking even after the app is killed?

在满足以下条件时,我在尝试启用持续位置跟踪时遇到问题:

发生上述情况时,位置更新将停止。我试图让我的服务器发送推送通知来唤醒应用程序,但如果应用程序被终止,它们不会到达。

令人费解的是,类似的功能似乎在 WhatsApp 上运行良好 (the live location)。在 WhatsApp 上,即使我禁用后台获取并终止应用程序,它也会以某种方式设法再次唤醒它以发送更新的位置信息。

有人知道他们在做什么吗?

使用 significant-change location 服务。即使应用程序已终止,它也能正常工作。

WhatsApp 似乎可以使用 PushKit to get around this problem. According to this question:

WhatsApp could be using VOIP background mode along with PushKit for solving this problem.

Voip pushes are:

  • delivered directly to the app.
  • considered high-priority notifications and are delivered without delay.
  • delivered even if the app was force-quit by the user.

我还创建了一个快速示例应用程序来尝试这个,它非常有效。然而,再次根据链接的问题,Apple 并没有真正允许这个解决方案:

Apple no longer allows the usage of the API for push notifications of non-VOIP apps. They do however allow WhatsApp to do it in their infinite fairness.