IOS 在应用终止时获取位置更新但未使用重大更改

IOS Getting location updates when app terminated without using significantChange

对于该主题的冗余,我深表歉意,但尽管给出了所有答案,但我无法确定应用程序终止时获取 accuracyBest 位置更新的可能性。 我不想使用 monitoringSignificantChange,我想要最好的准确性;我不会在 AppStore 上提交应用程序,因此 Apple 限制也不是问题。

我经历过这些:

-Location update even when app is killed/terminated

-

-Working with location updates when app is terminated

-http://mobileoop.com/getting-location-updates-for-ios-7-and-8-when-the-app-is-killedterminatedsuspended

还有很多,但不清楚是否可能。我目前有我的项目,使用 significantChange 一切都很好,但我现在需要更高的准确性。

有人可以直接告诉我是否可以在应用程序被杀死时获得最准确的位置更新吗?

无限感谢,

当您的应用终止时,持续的位置更新会停止。

地理围栏通知将重新启动您的应用程序,即使它不是 运行。我认为显着的位置更改也会重新启动您的应用程序,但我不太确定。

重新启动后,您可以再次开始位置更新,并将准确度设置为您想要的最佳位置,但我认为您需要使用这两个 API 之一来重新启动已被终止。

查看 Apple 文档中的以下内容,您显然有 2 个替代方案可以防止使用重大位置更改从后台唤醒应用程序。 我已经用粗体标记了您可以用来重新启动应用程序的服务,如果它已被终止。

Using Location Services in the Background Most location services are meant to be used while your app is in the foreground but some can also run in the background. In some cases, location events can even cause your app to be relaunched to process an event. To run most location services in the background, you need to enable the location updates background mode in the Capabilities tab of your Xcode project. For services that launch your app, you need to request (and be granted) “Always” authorization from the user.

The standard location service delivers events normally while an app is running in the foreground. When your app is in the background, this service delivers events only when the location-updates background mode is enabled for the app. This service does not relaunch iOS apps that have been terminated.

The significant location change service delivers events normally while an app is running in the foreground or background. For a terminated iOS app, this service relaunches the app to deliver events. Use of this service requires “Always” authorization from the user.

The region monitoring service delivers events normally while an app is running in the foreground or background. (You can use this service for both geographic and beacon regions.) For a terminated iOS app, this service relaunches the app to deliver events. Use of this service requires “Always” authorization from the user.

Beacon ranging delivers events normally while an app is running in the foreground. When your app is in the background, this service delivers events only when the location-updates background mode is enabled for the app and the standard location service is running. (If the beacon region’s notifyEntryStateOnDisplay property is YES, waking the device causes the app to range for beacons for a few seconds in the background.) This service does not relaunch iOS apps that have been terminated; however, you can be relaunched by monitoring beacon regions using the region monitoring service.

The heading service delivers events normally while an iOS app is running in the foreground. When your app is in the background, this service delivers events only when the location-updates background mode is enabled for the app and the standard location service is running. This service does not relaunch iOS apps that have been terminated.

The visit service delivers events normally while an iOS app is running in the foreground. When your app is in the background, this service delivers events only when the location-updates background mode is enabled for the app and the standard location service is running. For a terminated iOS app, this service relaunches the app to deliver events. Use of this service requires “Always” authorization from the user.

Enabling the location-updates background mode ensures that an app continues to receive location events while in the background. When the app moves to the background, the system adds the location-services indicator to the status bar to let the user know that an app is using location services. The system may still terminate the app at any time to reclaim its memory or other resources.

Also from the doc,

Getting the Visited Locations In iOS, the visits service provides an alternative to the significant location change service for apps that need location information about interesting places that the user visited. For example, if the user is in one location for an extended period of time, the service might generate an event when the user arrives at that location and another when the user leaves that location. The service is intended for apps that might already be using the significant location change service and want an even lower power way to do so. You would not use this service to create navigation apps or apps that rely on regular location updates.

文件Link:

https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/doc/uid/TP40007125-CH3-SW73