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

incomplete route data in Apple Health
When we upload workout data to HealthKit the route information with the workout detailed data is incomplete: just a few dots. When we select "Show all workout routes" the route data for the same workout shows correctly. We use the HKWorkoutBuilder to store the workout data, and add the location data with the HKWorkoutRouteBuilder to the workout with Is this an Apple Health issue, or do we have to change something in the way we store the location data to the workout?
3
0
328
6d
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.
3
0
320
1w
[WatchOS] Error while trying to insertRouteData into HKWorkoutRouteBuilder
I've ran into an error with the insertRouteData function of the HKWorkoutRouteBuilder that I can't seem to find any information on. The error is "Unable to find location series 1A193D3B-AFF5-41D8-A967-B1BE08D9F543 during data insert.". It seems to only happen when trying to insert very long routes, in the most recent case it was a 5 hour bike ride with 5900 samples. I save all the route data in a sqlite table as backup and after checking out the data there isn't any red flags as to why it would not insert correctly. Has anyone seen this before and could offer some insight or point me in the right direction to find the source of the error?
2
0
1.1k
1w
Treadmill integration and weighted vest with HealthKit
I don't understand why elevation data is not stored in the sample using a standard length unit. Why is it stored in HKQuantityTypeIdentifier.flightsClimbed (which is 10 feet)? Surely it is not a memory usage issue. Treadmill GATT provides elevation in meters. Using HKMetadataKeyElevationAscended for the total elevation gain throws away a lot of data. Why is there no support for weighted vest or backpack? Changing body weight is not the same and provides incorrect energy. Users want to compare workouts with different weights. I don't see any metadata key for carried weight.
2
0
71
1w
HealthKit backgroundDelivery is only triggering in the background while charging
HealthKit background delivery only triggers when charging. I have set step monitoring to hourly frequency. Despite step changes, callbacks fail to arrive after 3-4 hours on battery, but trigger immediately upon connecting power. Observed for 2 days: background updates are only received when charging. The device is not in Low Power Mode, and Background App Refresh is enabled for the app in Settings.
4
0
216
2w
How to detect when Apple Watch is removed from wrist during active workout session?
I'm currently collecting real-time heart rate data using HKWorkoutSession. I want to track when the Apple Watch is physically removed from the user's wrist during an active workout. However, I've noticed that workoutBuilder(_:didCollectDataOf:) continues to be called even after the watch is removed from the wrist. Is there a way to detect when the Apple Watch is removed from the wrist during an active HKWorkoutSession? Or is this tracking not possible through the HealthKit framework? Any guidance or alternative approaches would be appreciated.
2
0
140
2w
Bug apple Health
Hello everyone, I’m experiencing a visual issue when dismissing a sheet on iOS 26. I’m using the same implementation shown in the official Apple documentation. While testing, I noticed that some apps do not exhibit this behavior. However, when running this code on iOS 26, the issue consistently occurs. Issue description: The sheet dismisses abruptly A white screen briefly appears for a few milliseconds and then disappears This results in a noticeable visual glitch and a poor user experience I tested the exact same code on iOS 18, where the sheet dismisses smoothly and behaves as expected, without any visual artifacts. Has anyone else encountered this issue on iOS 26? Is this a known bug, or is there a recommended workaround? Any insights would be greatly appreciated. Thank you.
2
0
247
Dec ’25
Is it possible to distinguish real vs manually added running data in HealthKit?
I am developing an iOS application that utilizes running workout data from the iOS Health app / Fitness app via HealthKit, with explicit user permission. Before finalizing the app design, I would like to clarify several technical aspects related to data reliability, manual entry, record modification, and GPS route availability in HealthKit. My questions are as follows: 1. Identifying manually added (non-physical) running workouts When a running workout is created in the Health app without actual physical movement (for example, a workout manually added by the user), is there any metadata, flag, or key in HealthKit that allows developers to distinguish these records from workouts generated through actual motion tracking (iPhone or Apple Watch)? 2. Editing existing running workout records Is it possible for users, or for third-party apps with HealthKit write permission, to edit an existing running workout (e.g., distance, duration, calories) after it has been saved? • If edits are allowed, are the original values preserved in any way, or are they fully overwritten? 3. Detecting modified workout records If a running workout (whether originally auto-recorded or manually created) has been edited after creation, is there any identifier, metadata field, source revision, or versioning mechanism in HealthKit that allows developers to detect that the workout has been modified? 4. Access to GPS route / running path data For outdoor running workouts recorded with location services enabled: • Does HealthKit provide access to GPS route data (running paths / location traces) associated with a workout? • Is this route data accessible to third-party apps with user permission? • Is route data available only for workouts recorded on Apple Watch, or also for iPhone-only recordings? • Is there a way to determine programmatically whether a running workout includes valid GPS route data? The overall goal is to understand whether, when building an app that relies on HealthKit running data, it is technically possible to differentiate motion-based workouts from manually added or edited records, and to assess the availability of route information for outdoor runs. Any clarification or references to official documentation would be greatly appreciated. Thank you
1
0
96
Dec ’25
How to monitor heart rate in background without affecting Activity Rings?
I'm developing a watchOS nap app that detects when the user falls asleep by monitoring heart rate changes. == Technical Implementation == HKWorkoutSession (.mindAndBody) for background execution HKAnchoredObjectQuery for real-time heart rate data CoreMotion for movement detection == Battery Considerations == Heart rate monitoring ONLY active when user explicitly starts a session Monitoring continues until user is awakened OR 60-minute limit is reached If no sleep detected within 60 minutes, session auto-ends (user may have abandoned or forgotten to stop) App displays clear UI indicating monitoring is active Typical session: 15-30 minutes, keeping battery usage minimal == The Problem == HKWorkoutSession affects Activity Rings during the session. Users receive "Exercise goal reached" notifications while resting — confusing. == What I've Tried == Not using HKLiveWorkoutBuilder → Activity Rings still affected Using builder but not calling finishWorkout() (per https://developer.apple.com/forums/thread/780220) → Activity Rings still affected WKExtendedRuntimeSession (self-care type) (per https://developer.apple.com/forums/thread/721077) → Only ~10 min runtime, need up to 60 min HKObserverQuery + enableBackgroundDelivery (per https://developer.apple.com/forums/thread/779101) → ~4 updates/hour, too slow for real-time detection Audio background session for continuous processing (suggested in https://developer.apple.com/forums/thread/130287) → Concerned about App Store rejection for non-audio app; if official approves this technical route, I can implement in this direction Some online resources mention "Health Monitoring Entitlement" from WWDC 2019 Session 251, but I could not find any official documentation for this entitlement. Apple Developer Support also confirmed they cannot locate it? == My Question == Is there any supported way to: Monitor heart rate in background for up to 60 minutes WITHOUT affecting Activity Rings or creating workout records? If this requires a special entitlement or API access, please advise on the application process. Or allow me to submit a code-level support request. Any guidance would be greatly appreciated. Thank you!
0
0
146
Dec ’25
Perfect month award fitness app on iPhone
Hi! I have over 800 days strike in closing my move circle. However oerfect month badge is not popping up for November, we have now mid of Dec and still no update. I updated iOS to 26, did multiple resets and hard resets and still no badge. I checked many forums and post but any of given tips is working in my case. i know it sounds funny, but it’s frustrating that I’m not getting this little gold medal to keep me motivated 😅 does anyone know how to deal with it? Is it common issue?
2
0
97
Dec ’25
Can 3 party apps obtain Intervals information created using WorkoutKit?
I am developing a running training app that coaches can use to create interval workout plans. I can use HKWorkout to get information about Splits similar to that in Fitness app, but I can't get information about Intervals. My idea is to show interval details when users view their completed custom interval workout plans. Can I use Healthkit (or another feasible method) to get the actual distance or time of exercise in intervals workout ? (I know the workoutPlan property, but it doesn't reflect the segments of a real interval training workout.) Any insights or suggestions would be greatly appreciated! Thanks in advance!
0
0
148
Dec ’25
HKWorkoutSession.sendToRemoteWorkoutSession doesn't report success or failure
We are seeing an issue where sending data using the asynchronous method HKWorkoutSession.sendToRemoteWorkoutSession(data: Data) will never return in some cases (no success nor failure). This issue is happening for roughly 5% of Workouts started and will stay broken for the whole workout. The other 95% of the workouts, the connection works flawlessly. This happens on both watchOS 10 and 11, and with phones running iOS 17 or 18. The issue is quite random and not reproducible. Our app has thousands of workouts a day that use the workout session workout data send, with constant messages being send every few seconds. In some of those 5% cases the "sendToRemoteWorkoutSession" will throw way later, like 30+ minutes later, if the watch app is awake long enough to capture a log of a failure. Our code uses the same flow as in the sample project: https://developer.apple.com/documentation/healthkit/workouts_and_activity_rings/building_a_multidevice_workout_app Here is some sample code, which is pretty simple. Setup code: let workoutSession = try HKWorkoutSession(healthStore: healthStore, configuration: configuration) workoutSession.delegate = self activeWorkoutSession?.startMirroringToCompanionDevice { success, error in print("Mirroring started on companion device: \(success), error: \(error)") } workoutSession?.prepare() then later we send data using the workout session: do { print("Will send data") try await workoutSession.sendToRemoteWorkoutSession(data: data) print("Successfully sent data") // This nor the error may be called after waiting extensive amounts of time } catch { print("Failed to send data, error: \(error)") // This nor the success may be called after waiting extensive amounts of time } So far, the only fix is to restart the phone and watch at the same time, which is not a great user experience. Is anyone else seeing this issue? or know how to fix this issue?
2
0
731
Dec ’25
HKLiveWorkoutBuilder begincollection freezes in WatchOS simulator
The second time i start a workout session, the beginCollection instance method on HKLiveWorkoutBuilder freezes. To recreate run the Apple Sample Project Building a multidevice workout app. It looks like a bug with the HealthKit SDK and not the code but i could be wrong. The only workaround i found was erasing the simulator and reinstalling the app.
2
0
113
Dec ’25
HKLiveWorkoutBuilder begincollection freezes in sim
When calling beginCollection on HKLiveWorkoutBuilder the function never completes and gets stuck. (On the second workout session, the first session works flawlessly) To reproduce: Run the MirroringWorkoutsSample on WatchOS https://developer.apple.com/documentation/healthkit/building-a-multidevice-workout-app. Start the workout and then end the workouts it should work perfectly fine the first time. Start the workout and end again, and you should see the problem, the workout doesn’t end.
0
0
107
Dec ’25
WatchOS 26.1 - Steps Background delivery not working
I am using this below code since WatchOS 10 to set the user steps observer and get the callback of steps whenever changes. This is still working perfectly fine till watchOS 11 but when i updated to watchOS 26.1, I am not getting the callback of steps, like the observer is not working at all. I should get a callback inside query block whenever user take steps, but it is not working in watchOS 26.1. func setupStepCountObserver(completion: @escaping (Double, Double) -> Void) { let stepCountType = HKObjectType.quantityType(forIdentifier: .stepCount)! let query = HKObserverQuery(sampleType: stepCountType, predicate: nil) { [weak self] _, completionHandler, error in if let error = error { print("Error setting up observer query: \(error.localizedDescription)") return } // Fetch the latest step count data self?.getLast20SecTodaysSteps(completion: completion) // Call the completion handler to let HealthKit know you have processed the update completionHandler() } // Execute the query healthStore.execute(query) // Enable background delivery of updates healthStore.enableBackgroundDelivery(for: stepCountType, frequency: .immediate) { success, error in if let error = error { print("Error enabling background delivery steps: \(error.localizedDescription)") } else if success { print("Background delivery enabled for steps.") } } }
3
0
195
Nov ’25
HealthKit on macOS
HealthKit is currently not supported on macOS nor tvOS, despite being supported by visionOS. Support for macOS was last asked about[1] here in 2018. My goal is to display interactive data visualisations over workouts collected in HealthKit on macOS. Will this be possible to do in the near future using HealthKit directly? If not, can I somehow read the information from an iPhone and display it on the mac? Cheers, Rodrigo [1] https://developer.apple.com/forums/thread/94937
3
2
472
Nov ’25
Can a 3rd party app use WorkoutKit to store interval details?
I am the developer of a workout app that allows users to create interval programs (e.g. Warm Up, Fast, Cool Down). It is possible for me to store the data for the intervals along with the workout in the Health system by using WorkoutKit (or any other method)? My aim is to make it so that the Fitness app shows the interval details when users view workouts created by my app. Thanks in advance.
1
1
157
Nov ’25