-
Notifications
You must be signed in to change notification settings - Fork 281
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Calling AppleHealthKit.getWater() crashes the app on when HealthKit returns missing or undefined values (e.g. no water data). This happens in native code due to a nil value being inserted into an NSDictionary, which causes a fatal SIGABRT. The crash cannot be caught on the JS side, even with try/catch.
To Reproduce
Steps to reproduce the behavior:
- Ensure there are no water intake entries for the current day in Apple Health
- Call
AppleHealthKit.getWater({ date: new Date() }, callback)from React Native - Observe native crash before callback is triggered
Expected behavior
The native module should handle missing data gracefully:
- Return
nullor a safe fallback in the response - Or reject with an error via the callback. It should not crash the entire app.
Screenshots
N/A, but crash log excerpt:
*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[1]
Thread 14 Crashed:
4 0x204987ff0 __56-[RCTAppleHealthKit getWater:callback:]_block_invoke (RCTAppleHealthKit+Methods_Dietary.m:557)
Smartphone (please complete the following information):
- Device: iPhone 14
- OS: iOS 18.5 (22F76)
- Version: 1.18.0
Additional context
Looking at the native implementation of getWater, it appears sumQuantity or unit can be nil, and are inserted into an NSDictionary without nil checking.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working