rn-apple-healthkit
rn-apple-healthkit copied to clipboard
0.7.3 is not reading workouts, (while 0.6.5 is)
Same code, iOS 13. The latest version of this package lost the availability of reading workouts.

It seems, that this is caused by a recent change made in RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m
Workout is mapped to MindfulSession. If i use this permission instead, i see workouts again.
@IceDev-xyz @thkus I'll take a look at this issue today
It seems, that this is caused by a recent change made in
RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m
Workoutis mapped toMindfulSession. If i use this permission instead, i see workouts again.
You're right.
When I opened RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m file, I saw this:
if ([@"MindfulSession" isEqualToString: key] && systemVersion >= 10.0) {
return [HKObjectType categoryTypeForIdentifier:HKCategoryTypeIdentifierMindfulSession];
} else if ([@"MindfulSession" isEqualToString: key]){
return [HKObjectType workoutType];
}
and then I realised something a bit weird here: if ([@"MindfulSession" isEqualToString: key] is shown on both if statements.
So I changed the code from:
else if ([@"MindfulSession" isEqualToString: key]){
return [HKObjectType workoutType];
}
to:
else if ([@"Workout" isEqualToString: key]){
return [HKObjectType workoutType];
}
and now I can get workout data.
Thank you for pointing out. You just saved my day!
forked and used it here for now
https://github.com/paulmars/rn-apple-healthkit
const options = {
permissions: {
read: ["Height", "Weight", "SleepAnalysis", "MindfulSession", "Workout", "Steps"],
write: ["Height", "Weight"],
},
};
AppleHealthKit.initHealthKit(options, (err, results) => {
if (err) {
console.log("error initializing Healthkit: ", err);
return;
}
// Height Example
AppleHealthKit.getDateOfBirth(null, (err, results) => {
console.log(results)
});
});
@terrillo any update on this? can i create MR for this?
@terrillo any update on this? can i create MR for this?
For now, you can change content in package.json to:
"rn-apple-healthkit": "https://github.com/paulmars/rn-apple-healthkit",
and run rm -rf node_modules && yarn install again.
You can change it back later when the author has merged change.
I never brought this idea into production. Don't assume it works as desired. Comments or alterations welcome.