agencyenterprise / react-native-health

A React Native package to interact with Apple HealthKit
MIT License
873 stars 234 forks source link

iOS Fatal Exception: NSInvalidArgumentException RCTAppleHealthKit(Methods_Dietary) getWater:callback #294

Open KirillRodichev opened 1 year ago

KirillRodichev commented 1 year ago

Fatal Exception: NSInvalidArgumentException

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x9e38 __exceptionPreprocess
1  libobjc.A.dylib                0x178d8 objc_exception_throw
2  CoreFoundation                 0x1af078 -[__NSCFString characterAtIndex:].cold.1
3  CoreFoundation                 0x1ba3ac -[__NSPlaceholderDictionary initWithCapacity:].cold.1
4  CoreFoundation                 0x252b8 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]
5  CoreFoundation                 0x25158 +[NSDictionary dictionaryWithObjects:forKeys:count:]
6  Fitlink                        0x62a888 __56-[RCTAppleHealthKit(Methods_Dietary) getWater:callback:]_block_invoke + 495 (RCTAppleHealthKit+Methods_Dietary.m:495)
7  Fitlink                        0x63957c __101-[RCTAppleHealthKit(Queries) fetchSumOfSamplesOnDayForType:unit:includeManuallyAdded:day:completion:]_block_invoke + 562 (RCTAppleHealthKit+Queries.m:562)
8  libdispatch.dylib              0x2460 _dispatch_call_block_and_release
9  libdispatch.dylib              0x3f88 _dispatch_client_callout
10 libdispatch.dylib              0xb640 _dispatch_lane_serial_drain
11 libdispatch.dylib              0xc1c0 _dispatch_lane_invoke
12 libdispatch.dylib              0x16e10 _dispatch_workloop_worker_thread
13 libsystem_pthread.dylib        0xdf8 _pthread_wqthread
14 libsystem_pthread.dylib        0xb98 start_wqthread

Smartphone:

Possible fix Seems like the issue is the same as in https://github.com/agencyenterprise/react-native-health/issues/110 and should be fixed similarly to https://github.com/agencyenterprise/react-native-health/pull/280/

if ((!value && value != 0) || error != nil) {
    callback(@[RCTJSErrorFromNSError(error)]);
    return;
}
noahkurz commented 1 month ago

Facing the same issue