ios - 终止应用程序后我没有获取用户当前的运行位置

标签 ios swift mapkit mkmapview

当应用程序处于终止后台模式时,我需要用户运行位置和路线图路径。

目前我正在使用重要位置进行应用程序终止模式,但我们没有获得正确的距离和路线。 因为 didUpdateLocations 在某个特定的时间间隔后被调用,所以我没有获得正确的距离。 请指导。

最佳答案

根据苹果文档:

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.

这就是为什么 startMonitoringSignificantLocationChanges() 无法可靠地跟踪驾驶/公共(public)交通以外的用户位置变化。

现在,回到应用程序终止时必须跟踪用户位置的问题,不幸的是,您无法在应用程序终止时跟踪位置

If your app is terminated either by a user or by the system, the system doesn’t automatically restart your app when new location updates arrive. A user must explicitly relaunch your app before the delivery of location updates resumes. The only way to have your app relaunched automatically is to use region monitoring or the significant-change location service.

关于ios - 终止应用程序后我没有获取用户当前的运行位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46784621/

相关文章:

ios - 在 UITableView 中使用动态标签宽度管理自动标题高度

ios - AVURLAsset 已正确初始化,但有时其关联的 AVPlayerLayer 只会呈现黑色

ios - UIBarButtonItem 改变播放/暂停按钮的图像

ios - 是否可以在模态视图上设置 View ?

ios - 无法获取用户当前位置

iphone - Objective-C : Proper way to init an NSArray that is a @property

适用于 iPad I(和 iOS 5.1.1)的 iOS 应用程序

objective-c - 每当我在 Playground 上写几行代码时,XCode 都会挂起

ios - MapKit中的SLIDER-如何使用UISlider实现ZOOM?

ios - Swift Storyboard - 使用 calloutaccessorycontroltapped 公开按钮在 MapView 中创建一个 segue