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

Empty Active Calories burned and Total Calories burned

Open AhmedFarazQaimkhani opened this issue 1 year ago • 5 comments

Describe the bug I'm getting empty Active Calories burned and Total Calories burned in my app, while in Samsung health app I have calories.

To Reproduce const startOfDay = new Date(); startOfDay.setHours(0, 0, 0, 0); // Set to the beginning of the day

const endOfDay = new Date(); endOfDay.setHours(23, 59, 59, 999); // Set to the end of the day

await readRecords("TotalCaloriesBurned", { timeRangeFilter: { operator: "between", startTime: startOfDay.toISOString(), endTime: endOfDay.toISOString(), }, }).then((result) => { console.log("TotalCaloriesBurned Retrieved record: ", JSON.stringify({ result }, null, 2)); });

await readRecords("ActiveCaloriesBurned", {
  timeRangeFilter: {
    operator: "between",
    startTime: startOfDay.toISOString(),
    endTime: endOfDay.toISOString(),
  },
}).then((result) => {
  console.log("ActiveCaloriesBurned Retrieved record: ", JSON.stringify({ result }, null, 2));
});

Expected behavior I need active and total calories

Environment:

  • Health Connect Version: 2.0.1
  • React Native Version: 0.72.6
  • New architecture enabled: Yes

AhmedFarazQaimkhani avatar Apr 04 '24 09:04 AhmedFarazQaimkhani

Hi @AhmedFarazQaimkhani

I stumbled across the same 'issue.' However, I discovered that Google Fit, in my case, does not save calories into 'activeCaloriesBurned' but rather into 'totalCaloriesBurned.' Since you have tested both, it might be due to something else. Nonetheless, I recommend testing out with the Health Connect Toolbox if you haven't already, and try reading the values there.

Afterwards, we can better determine if the problem is related to Samsung Health, Health Connect, or this framework.

LeonNissen avatar Apr 10 '24 21:04 LeonNissen

@LeonNissen @AhmedFarazQaimkhani aI am facing the same problem, it is always empty

rousseau634 avatar Dec 02 '24 12:12 rousseau634

Have you all checked if data is present in Google Health Connect app? Are Google Fit and Health Connect sync enabled?

matinzd avatar Dec 02 '24 15:12 matinzd

@matinzd I noticed that Fit doesn't seem to grant Health Connect permission for ActiveCaloriesBurned. i tried to use the Health Connect Toolbox to insert ActiveCaloriesBurned, got a successful toast, but the result was still 0 image image

rousseau634 avatar Dec 03 '24 05:12 rousseau634

If you are also getting 0 in health connect toolbox as well, then the issue is not related to react native health connect. I can't help you with that.

matinzd avatar Dec 03 '24 08:12 matinzd