Not able to get WalkingRunningDistance over a period of time
emzudemo opened this issue · 0 comments
emzudemo commented
Hey guys!
First of all: Thank you for the great package.
From my understanding getting the walking+running Distance for a period of time works with getDailyDistanceWalkingRunningSamples()
But the data I get back doesn't seem to match the data within the Health app. And the dates are one month and one day off.
here's my code and what I get back.
import AppleHealthKit from 'rn-apple-healthkit';
const workoutData = [];
const startDate = new Date(2019, 10, 19).toISOString();
const endDate = new Date(2019, 10, 22).toISOString();
const permissions = {
permissions: {
read: ['DistanceWalkingRunning'],
write: []
}
};
const options = {
startDate,
endDate
};
AppleHealthKit.initHealthKit(permissions, (err, results) => {
if (err) {
console.log('error initializing Healthkit: ', err);
return;
}
AppleHealthKit.getDailyDistanceWalkingRunningSamples(
options,
(err: Object, results: Array<Object>) => {
console.log(results);
console.log(startDate);
console.log(endDate);
}
);
});
code gives back:
LOG [{"endDate": "2019-11-21T00:00:00.000+0100", "startDate": "2019-11-20T23:00:00.000+0100", "value": 14484.096000000001}, {"endDate": "2019-11-20T18:00:00.000+0100", "startDate": "2019-11-20T17:00:00.000+0100", "value": 72420.48}]
LOG 2019-11-18T23:00:00.000Z
LOG 2019-11-21T23:00:00.000Z
Here's the data in the health app
Screenshot