I am using (Always Allow) location permission in my iOS Xamarin Forms application. The problem I face today is that I'm unable to fully leverage ALWAYS permission in order to bring back my app (which was already killed) in the background whenever a location event occurs. Any Solution for that ?
My Code :
lm = new CLLocationManager
{
PausesLocationUpdatesAutomatically = false,
DesiredAccuracy=CLLocation.AccuracyBest,
DistanceFilter=0,
AllowsBackgroundLocationUpdates = true
};
lm.LocationsUpdated +=
(object sender, CLLocationsUpdatedEventArgs e) => {
var locations = e.Locations;
LocationEventArgs args = new LocationEventArgs();
args.lat = locations[locations.Length - 1].Coordinate.Latitude;
args.lng = locations[locations.Length - 1].Coordinate.Longitude;
locationObtained(this, args); //Log
};
lm.AuthorizationChanged += (object sender,
CLAuthorizationChangedEventArgs e) => {
if (e.Status == CLAuthorizationStatus.Authorized)
{
//lm.StartMonitoringSignificantLocationChanges();
lm.StartUpdatingLocation();
}
};
lm.RequestAlwaysAuthorization();
Thank you