react-native-health icon indicating copy to clipboard operation
react-native-health copied to clipboard

Using `getWater` crashes the app

Open AlbertoMeQ opened this issue 2 years ago • 3 comments

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)

AlbertoMeQ avatar Dec 22 '21 15:12 AlbertoMeQ

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);
                },
            )

AlbertoMeQ avatar Jan 05 '22 10:01 AlbertoMeQ

Did you find a fix for this?

brandon-austin-lark avatar Jul 01 '22 19:07 brandon-austin-lark

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.

jonstuebe avatar Aug 07 '22 21:08 jonstuebe