matinzd / react-native-health-connect

React native library for health connect (Android only)
http://matinzd.github.io/react-native-health-connect
MIT License
231 stars 43 forks source link

ExerciseSession is unable to retrieve heart rate data. #134

Open om1234ww opened 3 months ago

om1234ww commented 3 months ago

@matinzd

I want to get heart rate data using the ExerciseSession method, like this:

await  readRecords('ExerciseSession', {
      timeRangeFilter: {
        operator: 'between',
        startTime: '2024-02-01T12:00:00.405Z',
        endTime: '2024-05-04T12:00:00.405Z',
      },
    }).then((result: any) => {
      console.log(":::Ex---"+JSON.stringify(result))
     // data.workout = result[0];
    });
matinzd commented 3 months ago

Hey!

First of all, you are casting the result to any which is not ideal. Remove any to get the inferred types. Secondly, HeartRate is a separate entity. There is heart rate data inside ExerciseSession.

https://github.com/matinzd/react-native-health-connect/blob/9c87f4966de5f8263b25fe36f3bcdf22519a168f/src/types/records.types.ts#L103

om1234ww commented 3 months ago

@matinzd How do I retrieve heart rate data within an ExerciseSession?

matinzd commented 3 months ago

I don't know what you mean. But maybe you can check start and the end time of the exercise session and then match it with heart rate data. They are not aggregated together AFAIK. Please investigate this yourself.