Shiny.NET
GPS

The Global Position System (GPS) on Shiny is actually a bit more complicated than other Shiny modules as it can really "hammer" away on your resources if you set it up wrong.

|Area|Info| |---|---| |Description|| |Service|Shiny.Locations.IGpsManager |NuGet|| |Static Generated Class|ShinyGps

using Microsoft.Extensions.DependencyInjection;
using Shiny;

namespace YourNamespace
{
    public class YourShinyStartup : ShinyStartup
    {
        public override void ConfigureServices(IServiceCollection services, IPlatform platform)
        { 
            
<p>services.UseGps&lt;Shiny.Locations.IGpsDelegate&gt;();</p>
<p>services.UseGps();
services.UseGps 
        }
    }
}

Minimum Version: 8.0

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.org.yourapp" android:installLocation="preferExternal">
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-feature android:name="android.hardware.location.gps" />
    <uses-feature android:name="android.hardware.location.network" />
</manifest>

Minimum Version: 10

Info.plist

<?xml version="1.0" encoding="utf-8" ?>
<!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>
</dict>
</plist>

Package.appxmanifest

<?xml version="1.0" encoding="utf-8" ?>
<Package>
    <Applications>
    </Applications>
    <Capabilities>
        <DeviceCapability Name="location" />
    </Capabilities>
</Package>
using Microsoft.Extensions.DependencyInjection;
using Shiny;

namespace YourNamespace
{
    public class YourShinyStartup : ShinyStartup
    {
        public override void ConfigureServices(IServiceCollection services, IPlatform platform)
        { 
            
services.UseGps();

// OR

services.UseGps<GpsDelegate>();
 
        }
    }
}
using System;
using System.Threading.Tasks;
using Shiny.Infrastructure;


namespace Shiny.Locations
{
    public interface IGpsDelegate : IShinyDelegate
    {
        /// <summary>
        /// This is fired when the gps reading has changed. 
        /// </summary>
        /// <param name="reading">The gps reading.</param>
        Task OnReading(IGpsReading reading);
    }
}

using System.Threading.Tasks;
using Shiny.Locations;

public class GpsDelegate : IGpsDelegate
{
    public async Task OnReading(IGpsReading reading)
    {
    }
}
using System.Threading.Tasks;
using Shiny;
using Shiny.Locations;


public class GpsUsage
{
    public async Task Usage()
    {
        var manager = ShinyHost.Resolve<IGpsManager>();
        var result = await manager.RequestAccess(GpsRequest.Realtime(true));
        if (result == AccessState.Available)
        {
            //manager.WhenReading().Subscribe(reading =>
            //{

            //});
            await manager.StartListener(GpsRequest.Realtime(true));

            await manager.StopListener();
        }
    }
}