Post

Replies

Boosts

Views

Activity

Apple Watch HealthKit Queries Beyond 7 Days?
This has long been a frustration of mine on Apple Watch, and I've brought it up at WWDC labs every year to no avail but while the limitation on the Apple Watch to only be able to query 7 days of HealthKit data may have made sense early in the AW's lifetime for battery preservation etc., it really no longer makes sense in modern AW development. Especially not with stand alone watch apps, as a developer I am prohibited from building the same experience on the Apple Watch that I can in an iPhone app. For example, my app looks at your current health metrics and compares them to your 60 day baseline to identify any deviations from your normal ranges. I cannot create the same experience on the watch using purely HealthKit queries, and am limited to using either iCloud or Watch Connectivity which have their own drawbacks and are not an option for a stand alone watch app. Can we finally expand the length of HealthKit queries the AW can make so that we can build the same powerful experience on the watch that we can on iPhone? Thank you! Gary See also Feedback FB7649612 (from April 2020).
1
0
584
Jun ’24
Any changes in HRV sample frequency in watchOS 11?
Are there any changes in the frequency of HRV samples the Apple Watch takes in watchOS 11? Currently sample rates are very low except for users who have Afib History turned on. There should be some other way for users to get the benefit of more HRV sampling per day without needing to turn Afib History on if they haven't been diagnosed with Afib. Also is it possible for a 3rd party app to trigger an HRV sample? Thanks! Gary
2
1
983
Jun ’24
Determining crash on HKObject _validateForCreation
While testing on device (Apple Watch) attempting to save an HKWorkout into HealthKit I am adding samples of distance samples, calories, heart rates and vo2Max to the workout. Unfortunately unlike this question I am not getting as detailed as a trace back...as far as I can tell it's crashing on adding a sample but I can't tell which sample it is or why?Code:private func addSamples(toWorkout workout: HKWorkout, from startDate: Date, to endDate: Date, handler: @escaping (Bool, Error?) -> Void) { let vo2MaxSample = HKQuantitySample(type: HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.vo2Max)!, quantity: vo2MaxQuantity(), start: startDate, end: endDate) var samples = [HKQuantitySample]() for distanceWalkingRunningSample in distanceWalkingRunningSamples { samples.append(distanceWalkingRunningSample) } for energySample in energySamples { samples.append(energySample) } samples.append(vo2MaxSample) samples.append(contentsOf: heartRateValues) // Add samples to workout healthStore.add(samples, to: workout) { (success: Bool, error: Error?) in if error != nil { print("Adding workout subsamples failed with error: \(String(describing: error))") handler(false, error) } if success { print("Success, samples have been added, workout Saved.") //WorkoutStartDate = \(workout.startDate) WorkoutEndDate = \(workout.endDate) handler(true, nil) } else { print("Adding workout subsamples failed no error reported") handler(false, nil) } } }Trace:Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Triggered by Thread: 0 Application Specific Information: abort() called Filtered syslog: None found Last Exception Backtrace: 0 CoreFoundation 0x1bdf75e8 __exceptionPreprocess + 124 1 libobjc.A.dylib 0x1b15717c objc_exception_throw + 33 2 CoreFoundation 0x1bdf752c +[NSException raise:format:] + 103 3 HealthKit 0x273dbdde -[HKObject _validateForCreation] + 111 4 HealthKit 0x273dbc48 +[HKObject _newDataObjectWithMetadata:device:config:] + 219 5 HealthKit 0x273dbb30 +[HKSample _newSampleWithType:startDate:endDate:device:metadata:config:] + 159 6 HealthKit 0x273e9ba8 +[HKWorkout _workoutWithActivityType:startDate:endDate:workoutEvents:duration:totalActiveEnergyBurned:totalBasalEnergyBurned:totalDistance:totalSwimmingStrokeCount:totalFlightsClimbed:goalType:goal:device:metadata:config:] + 431 7 HealthKit 0x274a9342 +[HKWorkout workoutWithActivityType:startDate:endDate:workoutEvents:totalEnergyBurned:totalDistance:device:metadata:] + 109 8 HealthKit 0x274a9160 +[HKWorkout workoutWithActivityType:startDate:endDate:workoutEvents:totalEnergyBurned:totalDistance:metadata:] + 87Thread 0 name: Dispatch queue: com.apple.main-threadThread 0 Crashed:0 libsystem_kernel.dylib 0x1b9e443c __pthread_kill + 81 libsystem_pthread.dylib 0x1baec270 pthread_kill$VARIANT$mp + 3342 libsystem_c.dylib 0x1b96d28e abort + 1063 libc++abi.dylib 0x1b136cfe __cxa_bad_cast + 04 libc++abi.dylib 0x1b136e8a default_unexpected_handler+ 16010 () + 05 libobjc.A.dylib 0x1b1573e0 _objc_terminate+ 29664 () + 1026 libc++abi.dylib 0x1b1493fc std::__terminate(void (*)+ 91132 ()) + 67 libc++abi.dylib 0x1b148ed6 __cxxabiv1::exception_cleanup_func+ 89814 (_Unwind_Reason_Code, _Unwind_Exception*) + 08 libobjc.A.dylib 0x1b157274 _objc_exception_destructor+ 29300 (void*) + 09 CoreFoundation 0x1bdf7530 -[NSException initWithCoder:] + 010 HealthKit 0x273dbde2 -[HKObject _validateForCreation] + 11611 HealthKit 0x273dbc4c +[HKObject _newDataObjectWithMetadata:device:config:] + 22412 HealthKit 0x273dbb34 +[HKSample _newSampleWithType:startDate:endDate:device:metadata:config:] + 16413 HealthKit 0x273e9bac +[HKWorkout _workoutWithActivityType:startDate:endDate:workoutEvents:duration:totalActiveEnergyBurned:totalBasalEnergyBurned:totalDistance:totalSwimmingStrokeCount:totalFlightsClimbed:goalType:goal:device:metadata:config:] + 43614 HealthKit 0x274a9346 +[HKWorkout workoutWithActivityType:startDate:endDate:workoutEvents:totalEnergyBurned:totalDistance:device:metadata:] + 11415 HealthKit 0x274a9164 +[HKWorkout workoutWithActivityType:startDate:endDate:workoutEvents:totalEnergyBurned:totalDistance:metadata:] + 92
3
0
1.9k
Mar ’18