GeolocatorPlugin
GeolocatorPlugin copied to clipboard
xamarin form ios not work background mode and kill app
Bug Information
Version Number of Plugin: 4.5.0.6 Device Tested On: Simulator Tested On:iphone x 11.4.1 Version of VS: 15.8.3 Version of Xamarin: Xamarin.Forms 3.1.0.697729 Xamarin.iOS and Xamarin.Mac SDK 11.14.0.13 (373c313)
I'm trying to make the position update work even when the app is in the backgorund, and even when it's closed. with android everything works fine. with ios it only works in the simulator, just test in a physical device, it does not work if I put the app in the background. just from the backgorund I go in foreground calls me different want the event of the change of position even if I set every 20 seconds, how could I do?
Code snippet
`public MasterViewModel() { ListMasterPageItem = ListMenuService.GetMenuItems(); if (Device.RuntimePlatform == Device.iOS) { StartListening(); } }
async Task StartListening()
{
if (CrossGeolocator.Current.IsListening)
return;
///This logic will run on the background automatically on iOS, however for Android and UWP you must put logic in background services. Else if your app is killed the location updates will be killed.
await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(20), 10, true, new ListenerSettings
{
ActivityType = ActivityType.Other,
AllowBackgroundUpdates = true,
DeferLocationUpdates = false,
DeferralDistanceMeters = null,
DeferralTime = null,//TimeSpan.FromSeconds(1),
ListenForSignificantChanges = true,
PauseLocationUpdatesAutomatically = false
});
CrossGeolocator.Current.PositionChanged += Current_PositionChanged;
}`
###permission
I am currently experiencing the same issue and posted a question on SO here.