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

How to accurately query HKWorkout segment data
Hello, In my application, I need to obtain precise workout segment data from HKWorkout in order to calculate per-kilometer metrics such as heart rate and pace. My current approach is: 1.Use HKWorkout to fetch the associated HKWorkoutEvents. 2.Take the end time of one event as the start time of the next event to derive per-kilometer segment ranges. The issue I’m facing: •If a user sets Apple Watch to notify every 5 kilometers, then at 5 km, 10 km, 15 km, etc., I see overlapping event times. •From the HKWorkoutEvents data alone, I cannot distinguish between events that represent “per-kilometer splits” and those that represent “5-kilometer notifications.” •As a result, my per-kilometer heart rate and pace calculations can be inaccurate. My question is: Is there a recommended way to reliably differentiate per-kilometer splits from custom distance notifications and ensure accurate segment data retrieval? For example, should I instead reconstruct segments using HKWorkoutRoute and distance samples, rather than relying on HKWorkoutEvents? STEPS TO REPRODUCE 1.On Apple Watch, start an Outdoor Run using the Workout app. 2.In workout notifications, set distance alerts to every 5 kilometers. 3.During the run, when reaching 5 km, 10 km, 15 km, etc., the watch triggers notifications. 4.Query the corresponding HKWorkout from HealthKit and inspect its HKWorkoutEvents. 5.Notice that some event start times are duplicated, and it is unclear which events represent “per-kilometer splits” and which represent “5-kilometer notifications.” Expected Result: Be able to differentiate between per-kilometer splits and custom distance alerts, so that heart rate and pace per kilometer can be calculated accurately. Actual Result: The HKWorkoutEvents data contains duplicated event times without a way to distinguish event types, leading to inaccurate per-kilometer statistics.
3
0
102
3w
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
47
3w
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
71
2w
Apple Watch Ultra exercise app and activity rings won’t connect after charging
Since upgrading to iOS 26 beta on my Apple Watch Ultra and iPhone 16 Pro Max, my exercise app and activity rings have sporadically not connected after charging. Several recent mornings, when I’ve put my watch on, the activity rings are grayed out and when I click on them, they will show no activity, even though I have been active. Similarly, when I attempt to select the activity app, it will open, but when I select an activity, it will not start the workout. I’ve tried starting and restarting the watch and phone. I’ve checked permissions, and both the watch and phone are running the latest iOS. The only fix seems to be unpairing and repairing the watch and phone which is an absolute pain. Any assistance on how to permanently fix this would be greatly appreciated.
3
0
117
2w
HKObserverQuery and BackgroundDelivery Are Highly Unstable on watchOS 26
We are developing a health app that relies on HKObserverQuery and BackgroundDelivery to monitor Heart Rate data. On watchOS 10.6 and 11.6 , these data updates are typically delivered reliably every 8–12 minutes, occasionally exceeding 12 minutes, but generally not longer than 15 minutes. This frequency has been sufficient for the real-time data requirements of our app. However, after adapting our app to watchOS 26, we noticed that HKObserverQuery triggers much less frequently, with longer and very inconsistent intervals. This issue has had a major impact on our product: data collection for essential features is unreliable, resulting in a greatly diminished user experience on watchOS 26 and making the app essentially useless from the user’s perspective. Observed Behavior: HKObserverQuery and BackgroundDelivery are extremely unstable, with trigger intervals frequently exceeding 15 minutes, and sometimes even 20 minutes. When the user is sedentary, intervals become even longer; there are cases where no heart rate or active energy updates are delivered for 30 minutes, or even over 1 hour. Request for Support and Guidance: Have there been any changes to the HKObserverQuery background delivery mechanism on watchOS 26, specifically for Heart Rate and Active Energy data? If these changes are intentional system optimizations, could you provide guidance or recommended practices to ensure our app can reliably retrieve updates and maintain a smooth experience for users? Thank you for your support.
2
0
144
2w
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
105
2w
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
28
2w
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
78
2w
watchOS 26.0.2 / iOS 26.0.1 + Workout Session Mirroring Failure
Hi, I have a workout app in the App Store which mirrors workout data between the phone and watch. Since iOS 26.x I've been having issues and received reports of the mirroring no longer working. Users in iOS 18 have no problems with this functionality. Bug description: A workout session is started from the phone app and starts mirroring to the watch companion device. The watch starts the workout session and then the mirroring session is disconnected / lost. Sending data to the companion device fails and ending the session on the phone doesn't end the session on the watch...essentially they become completely disconnected. Please note I am testing this on physical devices...not simulators. As a sanity check I've also tried the "Building a multidevice workout app" sample code and it has the same problem. To re-create on the sample app, I start a workout from the phone, the watch workout starts and then the mirroring session seems to disconnect and is unable to send data. This is the log from the "Building a multidevice workout app" sample code. Successfully started workout Type: Notice | Timestamp: 2025-10-17 06:57:07.341401+02:00 | Process: MirroringWorkoutsSample Watch App | Library: MirroringWorkoutsSample Watch App.debug.dylib | Subsystem: com.example.apple-samplecode.MirroringWorkoutsSampleABC123.watchkitapp | Category: MirroringWorkoutsSampleForWatch | TID: 0x1b2ca7 -[SPRemoteInterface _appRecoverAnyExtendedRuntimeSession:]_block_invoke:4350: Got no sessions back from -[CSLSSessionService existingRunningSessions:] or -[CSLSSessionService existingScheduledSessions:] after receiving a PUICInitializeSessionServiceAction Type: Error | Timestamp: 2025-10-17 06:57:07.641571+02:00 | Process: MirroringWorkoutsSample Watch App | Library: WatchKit | Subsystem: com.apple.watchkit | Category: default | TID: 0x1b2ca7 Session state changed from 1 to 2 Type: Notice | Timestamp: 2025-10-17 06:57:07.647883+02:00 | Process: MirroringWorkoutsSample Watch App | Library: MirroringWorkoutsSample Watch App.debug.dylib | Subsystem: com.example.apple-samplecode.MirroringWorkoutsSampleABC123.watchkitapp | Category: MirroringWorkoutsSampleForWatch | TID: 0x1b2e87 Failed to send data: Error Domain=com.apple.healthkit Code=100 "Failed to send data to remote session." UserInfo={NSLocalizedDescription=Failed to send data to remote session.} Type: Notice | Timestamp: 2025-10-17 06:57:07.669922+02:00 | Process: MirroringWorkoutsSample Watch App | Library: MirroringWorkoutsSample Watch App.debug.dylib | Subsystem: com.example.apple-samplecode.MirroringWorkoutsSampleABC123.watchkitapp | Category: MirroringWorkoutsSampleForWatch | TID: 0x1b2ca7 Would appreciate any help with this problem as it's affecting customers. Thank you
3
0
115
5d
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
66
3d
Is there any way to access real-time sleep stage data from Apple Watch?
I'm trying to make a watchOS app that uses sleep data to wake users up when they enter lighter sleep stages. Apple has HealthKit, which exposes HKCategoryValueSleepAnalysis to view each stage throughout sleep, but unfortunately, this data is only written after the user wakes up. I did some research and found that the Apple Watch’s sleep classifier is part of Apple’s private system process, and apps can’t access that model directly or as it’s running. So, there’s no way to “record” my own data stream and match it with Apple’s classification during the night. Has anyone found a way to approximate or access live sleep-stage data in another way? I’m thinking of combining CoreMotion (for movement) and heart rate data from a HKWorkoutSession to infer stages myself, but I’m wondering if there’s any Apple-approved or more accurate approach for this. In other words, is there any way to use an Apple Watch to detect sleep stages accurately while the user is still asleep for the purpose of timing an optimal wake-up? Thanks
1
0
73
3d
HealthKit in React Native + Expo Dev Client: no authorization prompt (and no data)
Hi everyone, I’m building a health app with React Native using Expo Dev Client on a real iPhone. I need to read Apple Health (HealthKit) data, but the authorization sheet never appears—so the app never gets permissions and all queries return nothing. What I’ve already done Enabled HealthKit capability for the iOS target. Added NSHealthShareUsageDescription and NSHealthUpdateUsageDescription to Info.plist. Using a custom dev build (not Expo Go). Tested fresh installs (deleted the app), rebooted device, and checked Settings → Privacy & Security → Health/Motion & Fitness. Tried both packages: react-native-health and @kingstinct/react-native-healthkit. Same behavior: no permission dialog at first use. Ask Is there a known reason why the HealthKit permission sheet would not show on modern iOS when called from a React Native bridge (with Expo Dev Client)? Are there any extra entitlements, signing, or config-plugin steps required beyond HealthKit capability + Info.plist? If you’re successfully fetching Apple Health data from React Native on recent iOS, could you share the exact steps that made the permission sheet appear and data flow (Expo config/plugin used, Xcode capability setup, profile/team settings, build type, bundle ID nuances, any Health app reset steps, etc.)? This would help me and others hitting the same “authorized call but no prompt/no data” issue. Thank you!
1
0
55
2d