这个问题在这里已有答案:
您必须获取设备当前位置,为此我使用CLLocationManager类但didUpdateLocations没有调用。
我是
我的代码和plist如下:
<key>NSLocationAlwaysUsageDescription</key>
<string>Requires GPS to track persons</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Requires GPS to track persons</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Requires GPS to track persons</string>
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>location</string>
</array>
在viewdidLoad中添加它
locationManager.delegate = self
self.locationManager.allowsBackgroundLocationUpdates = true
self.locationManager.startUpdatingLocation()