GPS
Xamarin Essentials is great, but Shiny makes realtime background location updates a thing on Xamarin platforms.
Warning
Android uses a foreground service! You must have an application icon set or a drawable resource called notification in order for background GPS to work
Area | Value |
---|---|
NuGet | |
Delegate | Shiny.Locations.IGpsDelegate |
Startup File
using Microsoft.Extensions.DependencyInjection;
using Shiny;
namespace YourNamespace
{
public class YourShinyStartup : ShinyStartup
{
public override void ConfigureServices(IServiceCollection services, IPlatform platform)
{
services.UseGps();\n //OR\nservices.UseGps<YourGpsDelegate>();
}
}
}
Platform Setup
Minimum Version: 12
Info.plist
<!DOCTYPE plist PUBLIC " -//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version=\"1.0\">
<dict>
<key>NSLocationAlwaysUsageDescription</key>
<string>Say something useful here that your users will understand</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Say something useful here that your users will understand</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Say something useful here that your users will understand</string>
<key>UIBackgroundModes</key>
<array>
<string>location</string>
</array>
</dict>
</plist>