dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.28k stars 1.76k forks source link

Step Counter API #16712

Open Happypig375 opened 1 year ago

Happypig375 commented 1 year ago

Description

Implements an API that allows to interact with integrated Step Counter when available in order to have:

Public API Changes

public class StepCounter
{
    bool IsMonitoring { get; private set; }
    void Start();
    void Stop();
    event StepCounterChangedEventHandler ReadingChanged;
}
public class StepCounterChangedEventHandler : EventArgs
{
    DateTimeOffset Timestamp {get; private set}; // time of the most recent pedometer reading
    int TotalSteps {get; private set}; 
}

Android: https://developer.android.com/guide/topics/sensors/sensors_motion iOS: https://developer.apple.com/documentation/coremotion/cmpedometer UWP: https://docs.microsoft.com/en-us/uwp/api/windows.devices.sensors.pedometerreading

Intended Use-Case

To record steps using the step counter sensor, for health and sports app etc.

Happypig375 commented 1 year ago

Old issue here https://github.com/xamarin/Essentials/issues/362 Workaround here https://github.com/shinyorg/shiny

Xyncgas commented 1 year ago

not every platform has a step counter, maybe we can install a third party library and use it in platform specific code in MAUI, the third party library would give you access to that platform's pedometer instead of provided by MAUI framework because it's an UI framework

ghost commented 1 year ago

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

jfversluis commented 1 year ago

In the meantime, I've wrapped the basic functionality for iOS and Android in a plugin here: https://github.com/jfversluis/Plugin.Maui.Pedometer