Health & Fitness

RSS for tag

Explore the technical aspects of health and fitness features, including sensor data acquisition, health data processing, and integration with the HealthKit framework.

Health & Fitness Documentation

Posts under Health & Fitness subtopic

Post

Replies

Boosts

Views

Activity

Detecting Sleep End Events and Sleep Data Sync Timing from Apple Watch to HealthKit on iPhone
Hello, I’m developing an iOS app that works with sleep data from Apple Watch via HealthKit. I would like to clarify the following: How can an iPhone app detect when a sleep session ends on the Apple Watch? When is sleep data typically written to the HealthKit store on iPhone after sleep ends? Is it immediately after wake-up, or does it depend on certain conditions (e.g., watch charging, connectivity)? Understanding the timing and mechanism of sleep data synchronization is crucial for our app to process accurate and timely health information. Thank you for your assistance.
1
0
54
Apr ’25
Non-ViewModifier way to present WorkoutPlan preview
Hello, is there a way to present WorkoutPlan preview just like it was presented on WWDC video: https://developer.apple.com/videos/play/wwdc2023/10016/ with WorkoutCompositions? Or was this way ditched completely and is not possible to reproduce anymore? I find it weird that this view modifier accepts non-optional WorkoutPlan when the process of creating one can fail for many reasons with fatalError (that's another issue - why isn't there throws used anywhere?) when not checked with dedicated methods and I think that it would make more sense to create WorkoutPlan when user completes filling some kind of form. Because right now it's needed to compute the non-optional WorkoutPlan for the sake of .workoutPreview modifier live for any changes and that can often lead to errors. Non-modifier way of presenting the preview, like the one presented on WWDC would work really well for my project
1
0
115
Jun ’25
How to save medication dose with new HealthKit apis?
The recent WWDC presentation on HealthKit demonstrated how to associate side effects with a medication dose using HKObjectType.categoryType(forIdentifier:) and HKCategorySample, a subclass of HKObject. There also appears to be an object type specifically for medication doses: HKMedicationDoseEventType, accessible via HKObjectType.medicationDoseEventType(). However, there’s no corresponding public subclass of HKObject that supports this identifier. The most relevant class, HKMedicationDoseEvent, exists but has an inaccessible initializer. Is there currently a supported way to use HKMedicationDoseEventType, or is this functionality not yet available? https://developer.apple.com/videos/play/wwdc2025/321/
1
1
81
Jun ’25
Workout Buddy not available
Has anyone seen the workout buddy options on watch OS yet? I am not able to get it on my watch. My setup is an iPhone 16 and Watch Ultra 1 with the 26 OS I am currently using beta 3. English US language on both and US as region. I am located in Germany though. I restarted both devices multiple times without any changes. Hopefully someone can help.
1
0
71
Jul ’25
HKLiveWorkoutBuilder get wrong calorie data for iOS 26
In iOS 26, HKLiveWorkoutBuilder is supported, which we can use like HKWorkoutSession in watchOS - this is very exciting. However, it currently seems to have a bug in calculating calories. I tested it in my app, and for nearly 6 minutes with an average heart rate of 134, it only calculated 8 calories consumed (80 calories per hour), including basal consumption, which is obviously incorrect. (I used Powerboats Pro 2 connected to my phone, which includes heart rate data, and HKLiveWorkoutBuilder correctly collected the heart rate, which is great.) I think my code is correct. func workoutBuilder(_ workoutBuilder: HKLiveWorkoutBuilder, didCollectDataOf collectedTypes: Set<HKSampleType>) { for type in collectedTypes { guard let quantityType = type as? HKQuantityType else { return // Nothing to do. } let statistics = workoutBuilder.statistics(for: quantityType) if let statistics = statistics { switch statistics.quantityType { case HKQuantityType.quantityType(forIdentifier: .heartRate): /// - Tag: SetLabel let heartRateUnit = HKUnit.count().unitDivided(by: HKUnit.minute()) let value = statistics.mostRecentQuantity()?.doubleValue(for: heartRateUnit) let roundedValue = Double( round( 1 * value! ) / 1 ) if let avg = statistics.averageQuantity()?.doubleValue(for: heartRateUnit) { self.avgHeartRate = avg } self.delegate?.didUpdateHeartBeat(self, heartBeat: Int(roundedValue)) case HKQuantityType.quantityType(forIdentifier: .activeEnergyBurned): let energyUnit = HKUnit.kilocalorie() let value = statistics.sumQuantity()?.doubleValue(for: energyUnit) self.totalActiveEnergyBurned = Double(value!) print("didUpdate totalActiveEnergyBurned: \(self.totalActiveEnergyBurned)") self.delegate?.didUpdateEnergyBurned(self, totalEnergy: self.totalActiveEnergyBurned + self.totalBasalEneryBurned) return case HKQuantityType.quantityType(forIdentifier: .basalEnergyBurned): let energyUnit = HKUnit.kilocalorie() let value = statistics.sumQuantity()?.doubleValue(for: energyUnit) self.totalBasalEneryBurned = Double(value!) print("didUpdate totalBasalEneryBurned: \(self.totalBasalEneryBurned)") self.delegate?.didUpdateEnergyBurned(self, totalEnergy: self.totalActiveEnergyBurned + self.totalBasalEneryBurned) return default: print("unhandled quantityType=\(statistics.quantityType) when processing statistics") return } } I think I've found the source of the problem: let workoutConfiguration = HKWorkoutConfiguration() workoutConfiguration.activityType = .traditionalStrengthTraining //walking, running is ok workoutConfiguration.locationType = .outdoor When I set the activityType to walking or running, the calorie results are correct, showing several hundred calories per hour. However, when activityType is set to traditionalStrengthTraining or jumprope, the calculations are incorrect. PS: I'm currently using Xcode 26 beta3 and iOS 26 beta3. Hope this issue can be resolved. Thanks.
1
0
122
Jul ’25
Health Kit Background Delivery and URLSession.shared.dataTask
Hello. I have implemented background delivery for detecting changes in health kit with HKObserverQuery. It works well, I am reading changes. And I am sending this changes to an https endpoint with using an URLSession.shared.dataTask inside the HKObserverQuery callback while my app is terminated. I have several questions about this: Is starting a URLSession.shared.dataTask inside HKObserverQuery callback is correct way to do it? I am calling HKObserverQuery completion handler whatever dataTask returned success or failure but I am wondering what if the network connection is low and this dataTask response could not received in 2-3 seconds. I have read HealthKit background deliveries should take 1-2 seconds. Should I use background task somehow for sending those HTTPS requests?
1
0
103
Aug ’25
AppIntent, StartWorkoutIntent, and Siri
I'm a bit confused as to what we're supposed to be doing to support starting a workout using Siri in iOS/watchOS 26. On one hand, I see a big push to move towards App Intents and shortcuts rather than SiriKit. On the other hand, I see that some of the things I would expect to work with App Intents well... don't work. BUT - I'm also not sure it isn't just developer error on my part. Here are some assertions that I'm hoping someone more skilled and knowledgable can correct me on: Currently the StartWorkoutIntent only serves the Action button on the Watch Ultra. It cannot be used to register Shortcuts, nor does Siri respond to it. I can use objects inherited from AppIntent to create shortcuts, but this requires an additional permission to run a shortcut if a user starts a workout with Siri. AppIntent shortcuts requires the user to say "Start a workout in " - if the user leaves out the "in " part, Siri will not prompt the user to select my app. If I want to allow the user to simply say "Start a Workout" and have Siri prompt the user for input as to which app it should use, I must currently use the older SiriKit to do so. Are these assertions correct - or am I just implementing something incorrectly? Using the latest Xcode 26 beta for what it is worth.
1
1
128
Aug ’25
Best Practices for Continuous Background Biometric Monitoring on Apple Watch
Hello, everyone! I'm seeking some guidance on the App Store review process and technical best practices for a watchOS app. My goal is to create an app that uses HealthKit to continuously monitor a user's heart rate in the background for sessions lasting between 30 minutes and 3 hours. This app would not be a fitness or workout tracker. My primary question is about the best way to achieve this reliably while staying within the App Store Review Guidelines. Is it advisable to use the WorkoutKit framework to start a custom, non-fitness "session" for the purpose of continuous background monitoring? Are there any other recommended APIs or frameworks for this kind of background data collection on watchOS that I should be aware of? What are the key review considerations I should be mindful of, particularly regarding Guideline 4.1 (Design) and the intended use of APIs? My app's core functionality would require this kind of data for a beneficial purpose. I want to ensure my approach is technically sound and has the best chance of a successful review. Any insights or advice from developers who have experience with similar use cases would be incredibly helpful! Thank you!
1
0
296
Aug ’25
What determines which suggested apps are listed in Health?
Hello - I'm wondering about the suggested apps listed by Apple in their Health app. For example, if you select the "Sleep" category there are a bunch of suggested apps like AutoSleep and Sleepzy. These are not Sleep apps that I installed on my own phone or ever shared sleep data with. Is there a way to request to have a relevant app shown there? Or is it more automatic, like you're an app that integrates with HealthKit in certain ways and Apple has a way of determining that app is suitable for the user (ex. App Store popularity, user behavior, etc.)
1
0
105
Sep ’25
watchOS: CoreMotion data, Watch goes to sleep and disconnects during tests
Hello, I am working on a Iphone app and companion Watch app that prompts the user to go through a few activities like walk, sit, etc and collects the CoreMotion data from the Watch. The phone app coordinates the actions and sends a command to the watch to start/stop the measurement. My problem is that the Watch keeps on disconnecting after a few seconds and that is messing up the data collection. Is there a way to keep the watch awake and not sleep during the duration of these tests? I also used a HealthKit session to try and keep the watch awake and measuring.. but none of these methods are reliable.. Can you please suggest how to keep the watch and phone connected and awake during the data collection? (The whole test takes about 4-5 minutes).. I have spent many days on this problem.
1
0
56
Oct ’25
Feature Request: Expand HealthKit Body Composition Data Types to Support Smart Body Scanning Scales
Summary: Expanding HealthKit to support the full spectrum of smart scale metrics will allow Apple Health to remain the central hub for health data, align with user expectations, and future-proof the framework as body composition analysis evolves. Description: With the growing adoption of smart body composition scales (e.g. segmental impedance scanners, multi-frequency analyzers, and body pods), users are generating a wide variety of clinically relevant metrics that currently cannot be stored natively in HealthKit. At present, HealthKit supports a core set of body composition values (Body Mass, BMI, Body Fat %, Lean Mass, Height, Waist Circumference). While useful, these do not capture the full picture modern devices provide, leading to fragmentation: • Users can see dozens of metrics in the device app, but only a handful flow into Health. • Developers must resort to metadata fields, which are inconsistent across apps and not accessible in Apple’s Health app UI. This gap undermines HealthKit’s role as a central, standardized health record. ⸻ Proposed Additions: Expand HealthKit HKQuantityTypeIdentifier to include additional body composition and derived measurements commonly reported by smart scales: Core Body Composition • Visceral fat percentage / rating • Skeletal muscle mass • Segmental muscle mass (arms, legs, trunk) • Segmental fat mass (arms, legs, trunk) • Bone mineral mass • Total body water % / hydration Derived Health Metrics • Muscle-to-fat ratio • Phase angle (bioelectrical impedance) • Metabolic age • Basal metabolic rate (BMR) ⸻ Rationale: • User benefit: Health app would show a more complete health profile, not just weight and fat %. • Developer benefit: Creates standardized identifiers, eliminating the need for proprietary storage in metadata. • Industry alignment: Many leading health devices already provide these metrics; users expect them to sync into Health. • Future-proofing: As body scanning scales proliferate, HealthKit can remain the trusted central repository rather than ceding ground to siloed vendor apps. ⸻ Suggested Implementation: • Introduce new HKQuantityTypeIdentifier values for each metric. • Permit segmental values to be represented as discrete samples with metadata for body region. • Ensure values can be written by apps/devices and surfaced in Health app UI, just like existing body composition data.
1
0
78
Oct ’25
Unable to read HealthKit data on watchos26 while app is in the background
Hello, My watchOS app has been performing fine by requesting background app refresh and then requesting any new data from health kit in the background so that the widget can be updated. However, on watchos26 I have been unable to read data in the background, with any query returning zero results. That same data is clearly read just fine while in the foreground. Can anyone assist?
1
0
111
3w
Unable to receive HealthKit updates when app is force-quit — need clarification on background delivery limits
Hello, I’m developing a HealthKit-based fitness app in React Native that observes step count changes and uploads the latest totals to a remote server. I’m currently using HKObserverQuery with background delivery enabled (enableBackgroundDelivery(for:frequency:.immediate)), and the behavior works correctly while the app is running in the background or foreground. Whenever new step data is written to HealthKit, the app wakes up, reads the latest data, and sends it to my HTTPS endpoint using URLSession.shared.dataTask inside the observer callback. However, I’ve noticed the following issue: 1. If the user swipes up (force-quits) the app from the app switcher, the observer queries stop firing entirely. 2. In this state, even though HealthKit continues collecting step data from the device or Apple Watch, my app no longer receives those background deliveries until the user opens the app again. What I would like to achieve is: When the app is terminated (swiped up), and there are new step count updates in HealthKit, my app should still be able to receive those updates or be relaunched to handle them — similar to how some health companion apps continue syncing data and sending notifications even after being force-quit. So I have a few questions: Is this limitation expected — i.e., does iOS intentionally block HKObserverQuery background deliveries after a user force-quits the app? 2. Are there any special entitlements, background modes, or Apple-approved mechanisms that allow a health or medical app to continue receiving HealthKit changes even after a force-quit? 3. If not, what is the recommended architecture for apps that need to process HealthKit data continuously and send it to a backend server? For example, should such apps rely on server-side push notifications or CloudKit sync once the user reopens the app? My current goal is to ensure step count changes are uploaded reliably even if the app is killed, but I want to stay within the system’s supported behaviors and privacy constraints. Any clarification or guidance from Apple engineers or others who have implemented continuous HealthKit sync (like companion or medical apps) would be greatly appreciated. Thank you.
1
0
38
3w
watchOS 26.0.2+ Health Data Sync Failure - Series 7 - FB20533870
I'm reporting a critical Health data synchronization failure that began immediately after updating from watchOS 18 to watchOS 26.0.2 (stable release) and persists in watchOS 26.1 beta 2. Bug Description: Complete failure of Health data sync from Apple Watch to iPhone Health app. All health metrics are being captured and stored locally on the watch but fail to sync to the paired iPhone. Affected Data Types: Activity rings (Move, Exercise, Stand) Heart rate measurements Sleep tracking data Workout data All other HealthKit data points Environment: Device: Apple Watch Series 7 Initial failure: watchOS 26.0.2 (23R362) - stable release Current: watchOS 26.1 beta 2 (23S5052c) Paired iPhone: iPhone 17 Pro Max, iOS 26.1 beta 2 (23B5052c) Bluetooth and Wi-Fi connectivity: Normal Watch pairing status: Connected and functional for all other features Reproduction: Updated Apple Watch Series 7 from watchOS 18 to watchOS 26.0.2 on September 30, 2025 Health data sync ceased completely starting October 1, 2025 Issue persists after updating to watchOS 26.1 beta 2 and iOS 26.1 beta 2 Data remains stored locally on watch and is viewable in watch apps Apple Watch appears as connected data source in Health app but no data transfers Troubleshooting Performed: Multiple device restarts (both iPhone and Apple Watch) Bluetooth/Wi-Fi toggling and reconnection Verified Privacy > Motion & Fitness > Fitness Tracking and Health enabled on both devices Confirmed data source priority settings in Health app Extended charging periods to allow background sync operations Verified no Low Power Mode restrictions Impact: Critical functionality loss for primary Apple Watch use case. Unable to track longitudinal health data, breaking continuity of health records dating back to watchOS 18. Feedback Submitted: FB20533870 filed via Feedback Assistant with sysdiagnose from both devices Questions for Engineering: Is this a known regression in watchOS 26.0.2 or later builds? Are there any watchOS 26.1 beta release notes addressing HealthKit sync issues that I should review? Should I capture additional diagnostic data (e.g., specific console logs, HealthKit database states)? Is unpairing/re-pairing expected to resolve this, or would that indicate a deeper architectural issue? Additional Context: Apple Watch appears in Settings > Bluetooth as connected Can successfully change watch faces from iPhone Notifications, Messages, and calls work normally No previous sync issues prior to watchOS 26.0.2 Senior Apple Support advisor escalation completed; awaiting engineering review This appears to be a regression introduced in watchOS 26.0.2. Any guidance on additional diagnostics or confirmation of a fix in upcoming builds would be appreciated.
1
0
90
3w
Feature Request – Real-time HealthKit Streaming API for Trusted CarPlay Partners (e.g., Mercedes-Benz ENERGIZING)
Current HealthKit APIs provide access to heart-rate data through queries, but not as a true real-time stream. This limitation prevents systems such as Mercedes-Benz ENERGIZING from dynamically adapting the vehicle environment — including light, sound, seat massage and climate — to the driver’s physiological state. The ENERGIZING Coach developed by Mercedes-Benz uses continuous biometric feedback to enhance comfort, focus and safety by adjusting sensory stimuli based on live pulse data. Garmin wearables can already support this because they offer open Bluetooth Low Energy protocols. The Apple Watch, on the other hand, stores heart-rate data securely in HealthKit and makes it available through delayed write intervals. As a result, the current query mechanisms such as HKAnchoredObjectQuery or HKObserverQuery deliver updates with a latency of several seconds to minutes, which is too slow for the type of sub-second reaction required by driver-assistance or wellness systems. I would like to propose that Apple consider creating a real-time HealthKit streaming entitlement for verified partners such as automotive manufacturers participating in the CarPlay ecosystem. This entitlement could be limited to specific biometric signals like heart rate, heart-rate variability and stress index, and should function only when the user explicitly opts in. The data could travel one way from the iPhone to the vehicle head unit during an active CarPlay session, remain local and encrypted, and never be stored in the cloud. A latency of around half a second would be ideal. Technically, this could follow an asynchronous delegate model similar to HKLiveWorkoutBuilder or a Combine publisher interface adapted for CarPlay Health sessions. A capability like this would extend Apple’s health ecosystem beyond the wrist into the driving environment, allowing cars to respond in real time to the physical state of their drivers. It would strengthen Apple’s commitment to both privacy and safety, while supporting automotive partners that focus on human-centered design. Imagine a driver whose heart rate drops below a vigilance threshold: the Apple Watch detects it instantly, CarPlay transmits the signal securely to the ENERGIZING system, and the vehicle gently adjusts lighting and seat vibration to restore alertness. This kind of integration fits perfectly with Apple’s long-term vision of “Health Everywhere” and would make a measurable contribution to road safety and driver well-being. I would be happy to provide a more detailed use-case document or to collaborate with the Health Technologies and Car Experience teams to outline how this integration could be implemented securely and efficiently.
1
0
74
2w