出什么问题了?为什么第一次转换为后台模式“后台位置更新”会在不到30秒的时间内停止工作。
public LocationManager()
{
this.locMgr = new CLLocationManager
{
PausesLocationUpdatesAutomatically = false
};
locMgr.AllowsBackgroundLocationUpdates = true;
locMgr.DesiredAccuracy = 1;
locMgr.DistanceFilter = 1;
locMgr.StartUpdatingLocation();
}
我的信息.plist
<key>UIBackgroundModes</key>
<array>
<string>location</string>
</array>
<key>NSLocationAlwaysUsageDescription</key>
<string>This application needs access to a location.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This application needs access to a location.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This application needs access to a location.</string>
我的AppDelegate.cs
private CLLocationManager locationManager = new CLLocationManager();
public override void DidEnterBackground(UIApplication application)
{
Manager = new LocationManager();
Manager.StartLocationUpdates();
}