matinzd / react-native-health-connect

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

Getting Cummlative data from health connect #160

Closed GSSPawanKumarSingh closed 1 month ago

GSSPawanKumarSingh commented 1 month ago

we are migrating from Google Fit API to health connect. For this, we have implemented the flow. However, Today i found some inrelevant data in my application and when I dug into that, I found there are multiple application writing data to health connect like samsung Health, FitBit/Google Fit.

Use case

  1. In my phone there are 3 application Samsung Health/ FitBit and Google Fit which are recording steps independently. But at last they are writing data to Health connect.
  2. When I am going to fetch the steps, it is giving all cumulative steps, e.g. Samsung recorded 3000 Google Fit recorded 2900 and FitBit 2999 steps, and after fetching from Health Connect, it is giving 3000+2900+2999=8899.
  3. Is there any way to get that in segregated manner like when I fetch it will something sort of {samsung:3000,fitbit:2999,googlefit:2900} like this. currently I am using below methods to get aggregateRecord daySteps = await aggregateRecord({ recordType: 'Steps', timeRangeFilter: { operator: 'between', startTime: String(startDate), endTime: String(endDate), }, });

Please do let me know if there is any way to get that data.

GSSPawanKumarSingh commented 1 month ago

We have achieved by using Records to resolve the issue. However there is some issue regarding manual activities. As Health Connect not giving the correct value in metadata recordingMethod key it always giving 0 for unkown activity for all type of activities

User case : I have added some steps manually to Google FIT and some data automatically recorded but when I fetch the records then in metadata for both type of activity recording method is 0.

Please let me know if there is any workaround for that.

Thanks in Advance.

Snouzy commented 2 weeks ago

did u found a solution ?