react-native-health-connect icon indicating copy to clipboard operation
react-native-health-connect copied to clipboard

ExerciseSession is unable to retrieve heart rate data.

Open om1234ww opened this issue 1 year ago • 3 comments

@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];
    });

om1234ww avatar Aug 10 '24 10:08 om1234ww

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

matinzd avatar Aug 10 '24 11:08 matinzd

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

om1234ww avatar Aug 10 '24 12:08 om1234ww

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.

matinzd avatar Aug 10 '24 14:08 matinzd