kingstinct / react-native-healthkit

HealthKit bindings for React Native with TypeScript
https://kingstinct.com/react-native-healthkit/
MIT License
241 stars 49 forks source link

How to Use HKWorkoutSession and Start an Activity in React Native? #107

Open heritvithalani19 opened 2 months ago

heritvithalani19 commented 2 months ago

Hello,

I am trying to use HKWorkoutSession to start an activity from my React Native app using this library. However, I am unclear on how to correctly initiate a workout session and manage its lifecycle (start, pause, and end). Apple documentation

Specifically, I would appreciate guidance on the following:

How to correctly instantiate an HKWorkoutSession in React Native using this library. What parameters and configurations are required to start a workout session (e.g., workout type, activity options). Best practices for monitoring workout session status (active, paused, ended) and handling session completion. How to capture workout metrics like heart rate, calories, and distance during the session. Here is a brief overview of my current setup:

React Native version: 0.71.19 HealthKit permissions are already granted. Thank you for your assistance!

heritvithalani19 commented 2 months ago

@jonstuebe Can you please look?

robertherber commented 2 months ago

This is not currently featured in the library (saving and querying workouts are however). The approach we use at Kingstinct in regards to QuantitySamples (heart rate, calories burnt etc) is querying for those data points directly for the time period of the workout.

PRs are welcome and we're also open to helping out on a consulting basis.