在后台模式和终止模式的IOS中获取位置更新

时间:2019-06-14 18:21:34

标签: ios swift4 core-location

我希望获得用户的位置更新,即使该应用程序从后台模式终止或在后台模式下也是如此。这两种情况都必须起作用。请提供相同的任何演示链接。

1 个答案:

答案 0 :(得分:0)

您无法在终止模式下获取位置更新。

请参阅:-Getting User Current Location

要在后台获取位置,请使用以下代码进行授权

locationManager = CLLocationManager()
locationManager?.delegate = self
locationManager?.requestAlwaysAuthorization()

授权警报将显示为这样。

enter image description here

选择始终允许在后台模式下获取位置。

相关问题