Xamarin iOS Geolocator Background Service Dies in About 30 Minutes

I am currently using the Xamarin geolocation plugin found here:

https://github.com/jamesmontemagno/GeolocatorPlugin

To run location services in an application, I create using Xamarin Forms (PCL). I believe that I added permissions to the appropriate settings to allow this.

GPS works great when the application is active and locked (but with the application in the foreground). However, when the application moves to the background on iOS by pressing the home button, it still tracks the user and displays the message β€œThe application is using your location,” as I expected, but after a while between 30-40 minutes, this message disappears , and GPS appears to stop user tracking until they bring the app back to the forefront.

After the application has been brought to the forefront, it can be re-created again within 30-40 minutes to repeat the cycle.

I guaranteed that the locator object allows background updates:

public static Plugin.Geolocator.Abstractions.IGeolocator locator; locator = CrossGeolocator.Current; locator.AllowsBackgroundUpdates = true; locator.DesiredAccuracy = 20; 

Calling .PausesLocationUpdatesAutomatically indicates that it is a lie (in my opinion, this is the default value).

Edit

I have the following keys for info.plist:

 NSLocationWhenInUseUsageDescription NSLocationAlwaysUsageDescription 

Activated background location updates:

enter image description here

enter image description here

However, I did not enable background extraction, since Girish has the answers, is this something I need to do?

+5
source share
1 answer

Check if background mode is enabled for location updates.

enter image description here

0
source

Source: https://habr.com/ru/post/1262878/


All Articles