答案 0 :(得分:1)
<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()