perfood / capacitor-healthkit

Capacitor plugin to interact with HealthKit
https://www.npmjs.com/package/@perfood/capacitor-healthkit
62 stars 47 forks source link

Getting Inaccurate data for steps via getStatisticsCollection in v2 #42

Open Rahul-codoffer opened 1 month ago

Rahul-codoffer commented 1 month ago

Getting inaccurate step count form getStatisticsCollection method via v2

let startDate = "2024-10-07T00:00:00.000Z";
let endDate = "2024-10-07T23:59:59.000Z";
let anchorDate = "2024-10-07T00:00:00.000Z";

await CapacitorHealthkit.getStatisticsCollection({
        startDate,
        endDate,
        interval: {
          unit: 'day',
          value: 1
        },
        anchorDate,
        quantityTypeSampleName: 'stepCount',
      }).then(async (res: any) => {
        console.log("health data step", res);
      });
Received response - [ {
             "value": 12252,
            "startDate": "2024-10-07T00:00:00Z",
            "endDate": "2024-10-08T00:00:00Z"
        }]

But there is total 13,121 steps in my apple health

IMG_1328

``

Rahul-codoffer commented 1 month ago

i have fetched health data for the last one week and you can see the response its not accurate


     "data": [
        {
            "startDate": "2024-10-07T00:00:00Z",
            "value": 12252,
            "endDate": "2024-10-08T00:00:00Z"
        },
        {
            "endDate": "2024-10-09T00:00:00Z",
            "startDate": "2024-10-08T00:00:00Z",
            "value": 13917
        },
        {
            "startDate": "2024-10-09T00:00:00Z",
            "endDate": "2024-10-10T00:00:00Z",
            "value": 8855
        },
        {
            "startDate": "2024-10-10T00:00:00Z",
            "value": 6166,
            "endDate": "2024-10-11T00:00:00Z"
        },
        {
            "value": 6090,
            "endDate": "2024-10-12T00:00:00Z",
            "startDate": "2024-10-11T00:00:00Z"
        },
        {
            "endDate": "2024-10-13T00:00:00Z",
            "startDate": "2024-10-12T00:00:00Z",
            "value": 10423
        },
        {
            "value": 7022,
            "endDate": "2024-10-14T00:00:00Z",
            "startDate": "2024-10-13T00:00:00Z"
        },
        {
            "startDate": "2024-10-14T00:00:00Z",
            "endDate": "2024-10-15T00:00:00Z",
            "value": 555
        }
    ]

IMG_1334

Rahul-codoffer commented 1 month ago

@mahnuh may be it is issue of time zone ?  my current time zone is IST