当应用程序终止时iOS 10更新位置

当应用程序终止时iOS 10更新位置

问题描述:

我正在制作应用程序,显示用户与其他用户的距离。我可以在应用程序打开时以及应用程序在后台时更新用户位置。但是,当应用程序终止时,我无法弄清楚如何更新位置。我被告知这是不可能的,但我相信这是可能的,因为Life 360​​,Facebook等更新终止状态的位置。任何帮助如何实现这一点非常感谢!当应用程序终止时iOS 10更新位置

要做到这一点,你需要使用:

myLocationManager.startMonitoringSignificantLocationChanges()

从文档:

"If you start this service and your app is subsequently terminated, the system automatically relaunches the app into the background if a new event arrives."

从粗放

不幸的是测试显著变化时,他们开始来通过是非常不准确的,所以你可能希望在你收到信号的时候开启正常的位置更新背景中的位置变化很大。

myLocationManager.startUpdatingLocation()