Open s-turcheniuk opened 6 years ago
@terrillo Is there an update?
Hi @zumaawad and @terrillo, the saveFood
method doesn't save all the time and I'm not sure why. Have you guys got this working consistently? is there some configuration that I'm missing?
Can you please help 🙏
@zumaawad @Eyesonly88 would you guys mind sharing your code? Every time I try to use saveFood (or saveWater) my app crashes with EXC_BAD_ACCESS
let foodOptions = {
carbohydrates: 25,
energy: 1000,
fatTotal: 100,
protein: 50,
fiber: 20,
date: new Date().toISOString(),
mealType: "Breakfast",
foodName: "TestName"
};
AppleHealthKit.initHealthKit(
(healthKitOptions: Object),
(err: string, results: Object) => {
if (err) {
console.log("error initializing Healthkit: ", err);
return;
}
AppleHealthKit.saveFood(
(foodOptions: Object),
(err: Object, results: Object) => {
if (err) {
console.log("error saving water to Healthkit: ", err);
return;
}
}
);
}
);
@s-turcheniuk @Eyesonly88 @csumrell I found why it happens and fixed it. The issue was that the file that has saveFood method is not added into the project. This PR fixes it
I have a few questions about 'save food' feature:
Why it is not presented in read me while it is available in the source code?
I found that saveFood is not very stable. Sometimes it saves food, but most of the time it doesn't. Also, the callback function is not getting called when it doesn't save, which makes it is very hard to suggest what is going wrong. Any thoughts about it?