Shiny.Health 1.0.0-beta-0013

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
This is a prerelease version of Shiny.Health.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Shiny.Health --version 1.0.0-beta-0013
NuGet\Install-Package Shiny.Health -Version 1.0.0-beta-0013
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Shiny.Health" Version="1.0.0-beta-0013" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Shiny.Health --version 1.0.0-beta-0013
#r "nuget: Shiny.Health, 1.0.0-beta-0013"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Shiny.Health as a Cake Addin
#addin nuget:?package=Shiny.Health&version=1.0.0-beta-0013&prerelease

// Install Shiny.Health as a Cake Tool
#tool nuget:?package=Shiny.Health&version=1.0.0-beta-0013&prerelease

Shiny Health

Apple Health and Google Fit for your .NET7+ .NET Mobile apps

Features

  • Read summary values between timestamps and specified interval
  • Query distance, step count, calory intake, & heart rate
  • TODO: Write values

How To Use

IHealthService health; // inject, resolve, etc

// request permissions
var result = await health.RequestPermission(
    new Permission(DistanceHealthMetric.Default, PermissionType.Read),
    new Permission(CaloriesHealthMetric.Default, PermissionType.Read),
    new Permission(StepCountHealthMetric.Default, PermissionType.Read),
    new Permission(HeartRateHealthMetric.Default, PermissionType.Read)
);
if (!result)
{
    // say something useful
}

var end = DateTimeOffset.Now;
var start = DateTimeOffset.Now.AddDays(-1);

// now run your queries
var distance = (await health.Query(DistanceHealthMetric.Default, start, end, Interval.Days)).Sum(x => x.Value);
var calories = (await health.Query(CaloriesHealthMetric.Default, start, end, Interval.Days)).Sum(x => x.Value);
var steps = (await health.Query(StepCountHealthMetric.Default, start, end, Interval.Days)).Sum(x => x.Value);
var heartRate = (await health.Query(HeartRateHealthMetric.Default, start, end, Interval.Days)).Average(x => x.Value);

Setup

The fastest way to get going in a new application is to use our community dotnet template. Just run

dotnet new install Shiny.Templates

MAUI

Install Shiny.Health from NuGet

Now, in your MauiProgram.cs, add:


public static MauiApp CreateMauiApp()
{
    var builder = MauiApp
        .CreateBuilder()
        .UseShiny()
        .UseMauiApp<App>()
        .ConfigureFonts(fonts =>
        {
            fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
            fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); 
        });

    builder.Services.AddHealthIntegration();
    return builder.Build();
}

iOS

To use iOS (and therefore the sample), you need to have a provisioning profile with all of the necessary Apple Health setup for your application.

Take a look at the Xamarin docs for more info

Add the following:

Info.plist
<key>UIRequiredDeviceCapabilities</key>
<array>
        <string>healthkithealthkit</string>
</array>
<key>NSHealthUpdateUsageDescription</key>
<string>We need to say something useful here</string>
<key>NSHealthShareUsageDescription</key>
<string>We need to say something useful here</string>
Entitlements.plist
<key>com.apple.developer.healthkit</key>
<true />
<key>com.apple.developer.healthkit.background-delivery</key>
<true />
Google Fit

Official Android Documentation

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-android33.0 is compatible.  net7.0-ios was computed.  net7.0-ios16.1 is compatible.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed.  monoandroid12.0 is compatible. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed.  xamarinios10 is compatible. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-beta-0021 174 12/14/2023
1.0.0-beta-0020 85 12/5/2023
1.0.0-beta-0018 435 11/27/2023
1.0.0-beta-0013 123 10/4/2023
1.0.0-beta-0012 57 10/4/2023
1.0.0-beta-0006 89 9/5/2023
1.0.0-beta-0001 85 8/28/2023