react-native-health
react-native-health copied to clipboard
Using `getWater` crashes the app
Describe the bug
Thread 2: EXC_BAD_ACCESS (code=2, address=0x70000a798ff8)
is returned when using getWater
.
To Reproduce
let selectionOptions = {
date: new Date().toISOString(), // Now
}
AppleHealthKit.getWater(
selectionOptions,
(err, waterResults) => {
if (err)
{
console.log('[Water] error getting water: ', err);
}
else
{
console.log("Water: ", waterResults);
}
});
Expected behavior The function should return the correct value of water and not crash.
Smartphone:
- Device: Simulator (iOS 15.0)
Also saveWater
crashes the app when used:
let waterOptions = {
value: 1000,
date: new Date(Date.now() - (60 * 24 * 60 * 1000)).toISOString(), // yesterday
}
AppleHealthKit.saveWater(
(waterOptions),
(err, results) => {
if (err) {
return
}
console.log("Saved ", results, " water - on day: ", waterOptions.date);
},
)
Did you find a fix for this?
So not 100% if I've squashed the bug yet, but I'm calling isAvailable
first and so far I haven't had a crash.