- Run the application
- Switch to the background.
- “background location update” starts in the background, but it works less than a minute.
- I click on the application icon or go back to the application, the "location update" starts working
- Go back to the background. "background location update" now works long.
What is the problem? why the first transition to the background mode "background location update" stops working in less than 30 seconds.
public LocationManager()
{
this.locMgr = new CLLocationManager
{
PausesLocationUpdatesAutomatically = false
};
locMgr.AllowsBackgroundLocationUpdates = true;
locMgr.DesiredAccuracy = 1;
locMgr.DistanceFilter = 1;
locMgr.StartUpdatingLocation();
}
my info.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>
my AppDelegate.cs
private CLLocationManager locationManager = new CLLocationManager();
public override void DidEnterBackground(UIApplication application)
{
Manager = new LocationManager();
Manager.StartLocationUpdates();
}