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

Track workouts with HealthKit on iOS + GPS tracking
I've built an iOS app according to this WWDC25 video (https://developer.apple.com/videos/play/wwdc2025/322). I added GPS tracking for workouts. In Xcode, I've enabled Signing & Capabilities > Background Modes: Location Updates. And in my code, I request CLAuthorisationStatus.authorizedAlways. Everything works as expected, but I am unsure if .authorizedWhenInUse will not be sufficient for this kind of app. It seems even to work when I use .authorizedWhenInUse as either the Dynamic Island or the Live Activity is shown when the app is not in the foreground. I need clarification by an expert.
0
0
62
3d
technical clarification on sensorkit measurement sampling
Dear SensorKit team, We are currently working with SensorKit ambient light data under our approved SensorKit entitlement for research use. We would be grateful for some technical clarification on the sampling strategy for the SRSensor.ambientLightSensor stream, as this directly affects how we analyse and report the data. In exported data from Apple Watch, we observe that ambient light samples do not appear to follow a fixed sampling cadence. Instead, the data appear burst-like: in one short window, we see many samples with inter-sample intervals around 100 ms, occasional near-duplicate timestamps, and then gaps of around 10 to 30 seconds with no samples. This suggests that the stream may be adaptive, event-triggered, buffered, or subject to system-level sampling decisions. We also noticed a related discrepancy when comparing the SensorKit ambient light trace with the Health app display for a corresponding Time in Daylight sample. In one example, the Health app shows a 5-minute Time in Daylight interval with a “Maximum Light Intensity” value of 9,493 lux. In the SensorKit ambient light trace around that period, the raw samples show a different maximum depending on the precise time window considered, including higher values shortly before the HealthKit interval start and lower values within the subset of SensorKit samples we inspected. We realise that Time in Daylight may be generated by a separate internal aggregation or classification pipeline, but this comparison raised the question of how closely SensorKit ambient light samples should be expected to correspond to the light intensity values displayed in Health. Could you clarify the following points for SensorKit ambient light data? Is SRSensor.ambientLightSensor sampled at a fixed cadence, or is sampling adaptive / event-driven? If sampling is adaptive, what factors influence sampling density? For example, changes in illuminance, device or wrist motion, device orientation, display state, app state, power state, charging state, or other system-level conditions. Are ambient light readings buffered and delivered or exported in bursts? Do SensorKit timestamps correspond to the physical sensor acquisition time, processing time, or the time at which the sample is made available through SensorKit? Are duplicate or near-duplicate ambient light samples expected in SensorKit exports? Are there circumstances under which ambient light sampling is suspended, downsampled, or suppressed? Is SensorKit ambient light expected to match, approximate, or differ from the light intensity values shown in Health app Time in Daylight sample details? Is the “Maximum Light Intensity” shown for Time in Daylight computed from the same underlying ambient light sensor stream exposed through SensorKit, or from a separate internal stream or aggregation? Are there recommended practices for analysing SensorKit ambient light data, especially with respect to irregular sampling, burst sampling, missing intervals, and aggregation to longer time windows? Is the sampling strategy the same across Apple Watch hardware versions, or should researchers expect device-specific differences? We do not need proprietary implementation details. Our goal is to understand the methodological constraints well enough to analyse the data appropriately and describe the limitations accurately in scientific work. Thank you!
1
0
97
5d
Apple Watch awards missing after iPhone iCloud restore
Hello forum-community I hope you're all doing well. My Iphone recently went to apple in order to fix an issue with my camera. After I received it back, I loaded a Backup from ICloud I made before the Iphone went to Apple. So far so good. The Back Up took very long to load onto the device. Especially the apps downloading took almost four hours but I was also fine with that. When the BackUp was finished I had some bugs in some apps like yazio. Some scaling issue led to the app zooming in and out every time I tried to open Yazio. Not really a big deal but it somehow it annoyed me, so I upgraded the Ios from stable 26.5.1 to public beta 26.6 . Enough context. Now my problem: There must have went something wrong while loading the backup. All my workouts from 2023-today, all monthly medals, all other fitness data can be seen in the app. Most medals in the category „workouts“ somehow did NOT sync properly so it looks like I never completed a workout at all. What I've tried so far: Restored both my iPhone and Apple Watch from backups. Verified that all workout history is present (workouts since 2023 are intact). Verified that monthly challenges are still present. Verified that Health data appears complete and correct. Verified that activity data (Move, Exercise, Stand) is present. Confirmed that workout records are correctly stored in the Fitness and Health apps. Updated the iPhone to the latest iOS beta version. Unpaired and re-paired the Apple Watch. Restored the Apple Watch from an older backup. Allowed several days (approximately 5+ days) for Fitness and Health data to resynchronize. Kept both devices connected to Wi-Fi and charging for extended periods. Confirmed that some achievements (e.g. Longest Move Streak) are displayed correctly. Confirmed that many Workout Awards are missing or shown as not earned. Confirmed that some “Close Your Rings” awards are incorrect or missing. Confirmed that awards for workouts already completed after the restore (e.g. Walking Workout, Running Workout) remain greyed out. Confirmed that newly completed qualifying workouts are recorded correctly but do not trigger the corresponding awards. Verified that the issue persists after restoring the Apple Watch from a different backup. Contacted Apple Support. Apple Support declined further troubleshooting because the iPhone is running a beta version of iOS and recommended restoring to a non-beta version (already did that - result: no fitness data at all) Any more suggestions on how to fix this? Thanks everybody!
1
1
256
1w
Unable to invalidate interval: no data source available error when fetching steps using HKStatisticsCollectionQuery
While attempting to read a user’s daily step history spanning backward to the last 7 days, a small but consistent subset of users encounter Error Code 3 with the underlying error description: Error Code 3 "Unable to invalidate interval: no data source available." When this error occurs, we are entirely unable to read their step history. We have received ~10 direct user reports of this within the last couple of weeks.
14
2
1.3k
1w
Feature Proposal: Apple Intelligence Guided Workouts for Apple Watch
Hi everyone, After watching WWDC26 and going for a run today, I came up with an idea that I believe could be a natural extension of Apple Intelligence and Apple Watch. This proposal is not intended to replace Custom Workouts. Instead, it focuses on removing the manual setup required to create them by allowing Apple Intelligence to understand workout plans written in natural language. Today, Apple Watch already supports Custom Workouts, but users still have to manually recreate interval workouts. For example: • Walk 5 minutes • Run 1 minute • Walk 1 minute 30 seconds • Repeat 6 times Instead, Apple Intelligence could understand workouts written in natural language and automatically generate a structured Apple Watch workout. This could work from multiple sources: Notes Messages Mail PDFs Screenshots Photos of printed training plans Websites The generated workout could then be reviewed by the user before being saved and synchronized to Apple Watch. Intelligent Haptics I also imagined an optional feature called Intelligent Haptics. Instead of using a single vibration for interval transitions, the watch could communicate through different haptic patterns: Progressive vibration before a running interval starts. Decreasing vibration when an interval ends. Rhythmic vibrations during recovery to help regulate breathing. The goal isn't simply to notify the user—it is to reduce the need to constantly look at the display and allow them to stay focused on the workout. Since Apple Intelligence is becoming a system-wide capability, I think workouts could be understood just like calendar events, reminders or emails. I have already submitted this proposal through Feedback Assistant, but I would love to hear what other developers think. Would this be a feature you would like to see in watchOS? I'm curious to hear how other developers would improve this concept.
0
0
158
1w
HKStatisticsCollectionQuery initialResultsHandler returns nil results (error) for one specific user — read auth granted, data exists, survives reinstall
Environment: iPhone 13 Pro, iOS 26.5. Affects a single user out of many; cannot reproduce on any of our test devices. We use HKStatisticsCollectionQuery to read step counts for a statistics screen. For one specific user, the query's initialResultsHandler appears to deliver results == nil (the success branch never runs), so our completion is never called and the screen shows an infinite spinner. private let store = HKHealthStore() func fetchHourlyStepCounts(for day: Date, completion: @escaping ([Int]) -> Void) { guard let stepType = HKQuantityType.quantityType(forIdentifier: .stepCount) else { return } let calendar = Calendar.current let startOfDay = calendar.startOfDay(for: day) var hourly = DateComponents() hourly.hour = 1 let query = HKStatisticsCollectionQuery( quantityType: stepType, quantitySamplePredicate: nil, options: .cumulativeSum, anchorDate: startOfDay, intervalComponents: hourly ) query.initialResultsHandler = { _, collection, error in guard let collection else { // For the affected user, execution seems to reach here (collection == nil). // Adding logging of the HKError + authorization status for the next occurrence. return } var counts: [Int] = [] let end = calendar.date(byAdding: .day, value: 1, to: startOfDay)! collection.enumerateStatistics(from: startOfDay, to: end) { stats, _ in let steps = stats.sumQuantity()?.doubleValue(for: .count()) ?? 0 counts.append(Int(steps)) } DispatchQueue.main.async { completion(counts) } } store.execute(query) } What we've confirmed / ruled out: Read authorization for stepCount is granted (the user toggled it ON in the HealthKit sheet on video). The Apple Health app shows step data for this user (so data exists). A coarser query (2-year interval) for the same user succeeds, while the hourly query appears to fail — same type / predicate / options / auth. Symptom persists across app reinstall and device reboot, and re-granting Health permission. Permission denial returns empty results (per Apple docs), not an error — so this isn't simple denial. Not errorDatabaseInaccessible as far as we can tell (foreground, device unlocked). Questions: What can cause HKStatisticsCollectionQuery.initialResultsHandler to return results == nil (with an error) persistently for one device/account, when read auth is granted and data exists? Can errorHealthDataRestricted occur without an MDM/supervised profile (i.e., on a normal consumer device)? What device/account states actually trigger it? Is it expected that a coarse-interval query succeeds while an hourly-interval query on the same type fails for the same user? We're adding logging of the actual HKError code + authorizationStatus for the next occurrence, but would appreciate any insight on what conditions produce this.
0
0
177
1w
Why does a watchOS HKLiveWorkoutBuilder soccer workout report shorter totalDistance than Apple Workout soccer?
I’m developing a watchOS app that records outdoor soccer workouts using HealthKit. My app starts a workout session with: HKWorkoutConfiguration.activityType = .soccer HKWorkoutConfiguration.locationType = .outdoor HKWorkoutSession HKLiveWorkoutBuilder HKLiveWorkoutDataSource During the workout, I display distance from the live builder statistics: HKQuantityType.quantityType(forIdentifier: .distanceWalkingRunning) After the workout ends, I save the workout using finishWorkout(), and later read the saved distance from: HKWorkout.totalDistance?.doubleValue(for: .meter()) So the total distance shown in my app is not calculated manually from GPS route points. It comes from HealthKit’s workout distance. I noticed a difference between soccer workouts recorded by Apple’s built-in Workout app and soccer workouts recorded by my third-party watchOS app. Example comparison: Apple Workout app soccer: Active duration: about 88 min Steps: about 8,832 Distance: about 6.7 km No visible route/location data in Fitness My watchOS app soccer: Active duration: about 87 min Steps: about 8,998 Distance: about 5.6 km Includes route/location data Workout recorded through HKWorkoutSession + HKLiveWorkoutBuilder Distance read from HKWorkout.totalDistance The step counts and active durations are very close, but the distance differs by about 1.1 km. One important detail is that the Apple Workout app soccer workout does not appear to include visible route/location data in Fitness, while my third-party workout does include route/location data. Despite that, the Apple Workout app reports a longer distance. So the comparison is not simply “GPS route distance vs GPS route distance”. It looks like the built-in Workout app may be estimating soccer distance without exposing route data, while HKLiveWorkoutBuilder for a third-party .soccer workout may be producing a different totalDistance estimate. My questions are: When the built-in Apple Workout app records an outdoor soccer workout without exposing route data, how is totalDistance estimated? Is that distance estimation behavior available to third-party watchOS apps using HKWorkoutSession + HKLiveWorkoutBuilder with .soccer? If a third-party app records route data for the same soccer activity, can that change how HealthKit calculates totalDistance compared with a no-route built-in Workout app recording? For third-party soccer workouts, should developers expect HKWorkout.totalDistance to match the built-in Workout app, or is a difference expected? Is there any additional configuration, entitlement, data type, or best practice required to get more accurate distance estimates for soccer workouts? Any clarification on the expected behavior would be very helpful. Thanks!
0
1
264
2w
WorkoutKit Feature Request: Distance & Time based IntervalBlock
Today, IntervalBlock only supports a fixed iteration count: IntervalBlock(steps: [IntervalStep], iterations: Int) This works well when the athlete knows exactly how many rounds they want to perform, but a lot of structured running and cycling workouts terminate a repeating block based on cumulative distance or cumulative elapsed time instead. These constructs are first-class on Garmin Connect, TrainingPeaks, FinalSurge, and similar platforms, but there's no way to express them in WorkoutKit's CustomWorkout. We've had to either fall back to a fixed iteration count (which forces us to guess the user's pace) or skip Apple Workout scheduling for these workouts entirely, which is a poor experience for athletes on watchOS. Proposal: // Today (still supported) IntervalBlock(steps: steps, iterations: 5) // Proposed IntervalBlock(steps: steps, until: .distance(5, .kilometers)) IntervalBlock(steps: steps, until: .time(30, .minutes)) IntervalBlock(steps: steps, iterations: 8) // unchanged Example Workouts with proposed features: "Run/walk until 5 km" Run for a minute, then walk for 30 seconds until completing a 5K. "30-minute fartlek" Repeat a hard/easy pair until cumulative time hits 30 min "10 km tempo with surges" Surge/recover until total distance hits 10 km. FB: FB23359408
0
0
220
2w
Apple Watch awards missing after iPhone iCloud restore
Hello forum-community I hope you're all doing well. My Iphone recently went to apple in order to fix an issue with my camera. After I received it back, I loaded a Backup from ICloud I made before the Iphone went to Apple. So far so good. The Back Up took very long to load onto the device. Especially the apps downloading took almost four hours but I was also fine with that. When the BackUp was finished I had some bugs in some apps like yazio. Some scaling issue led to the app zooming in and out every time I tried to open Yazio. Not really a big deal but it somehow it annoyed me, so I upgraded the Ios from stable 26.5.1 to public beta 26.6 . Enough context. Now my problem: There must have went something wrong while loading the backup. All my workouts from 2023-today, all monthly medals, all other fitness data can be seen in the app. Most medals in the category „workouts“ somehow did NOT sync properly so it looks like I never completed a workout at all. What I've tried so far: Restored both my iPhone and Apple Watch from backups. Verified that all workout history is present (workouts since 2023 are intact). Verified that monthly challenges are still present. Verified that Health data appears complete and correct. Verified that activity data (Move, Exercise, Stand) is present. Confirmed that workout records are correctly stored in the Fitness and Health apps. Updated the iPhone to the latest iOS beta version. Unpaired and re-paired the Apple Watch. Restored the Apple Watch from an older backup. Allowed several days (approximately 5+ days) for Fitness and Health data to resynchronize. Kept both devices connected to Wi-Fi and charging for extended periods. Confirmed that some achievements (e.g. Longest Move Streak) are displayed correctly. Confirmed that many Workout Awards are missing or shown as not earned. Confirmed that some “Close Your Rings” awards are incorrect or missing. Confirmed that awards for workouts already completed after the restore (e.g. Walking Workout, Running Workout) remain greyed out. Confirmed that newly completed qualifying workouts are recorded correctly but do not trigger the corresponding awards. Verified that the issue persists after restoring the Apple Watch from a different backup. Contacted Apple Support. Apple Support declined further troubleshooting because the iPhone is running a beta version of iOS and recommended restoring to a non-beta version (already did that - result: no fitness data at all) (Device iPhone 17 Pro Max - Apple Watch Series 9) Any more suggestions on how to fix this? Thanks everybody!
5
0
269
2w
HealthKit multiple queries performance questions
We're building two apps that rely almost exclusively on HealthKit, so we run a high volume of queries against a single shared HKHealthStore — mostly HKSampleQuery, plus HKStatisticsQuery and HKQuantitySeriesSampleQuery where needed. We also use HKObserverQuery for background processing and widget updates. The data is sleep, body metrics, and workouts. As our feature set grew, so did data-loading time, to the point of being a noticeable annoyance for users. To speed things up we moved from serial to concurrent queries. Mechanism: we issue the batch via a ThrowingTaskGroup — each child task calls execute() and awaits the completion handler through a continuation — with up to ~30 queries in flight concurrently against the one shared store. Symptom: The app doesn't freeze and the queries start fine, but their results sometimes take 30s+ to come back. Most of the times the same data fetch takes only a couple of seconds. There's no clear pattern except that it happens far more often on foregrounding. Environment: Devices we use for testing are iPhone 17 Pro and iPhone 15 pro both running iOS 26.5. Since the symptoms are hard to catch we're using text file logging to time the data layer responses. We're considering bounding concurrency to a small N via a capped task group, or reverting to serial — but both feel like either a regression or added complexity we can't justify without understanding the real cause. Questions: When we start ~30 queries at once against a single HKHealthStore, does HealthKit actually run them in parallel, or do they get handled one-at-a-time (or rate-limited) behind the scenes? Is there a sensible upper limit on how many queries we should run at once? Should we cap it to a small number, or does that not help because the system serializes them anyway? (Also: is sharing one HKHealthStore across the app the right approach?) Why would this happen mainly when the app comes to the foreground? A few possibilities we'd like confirmed or ruled out: the device hasn't been unlocked yet so health data isn't available, the connection to the HealthKit service is being re-established after backgrounding, general contention, or our background HKObserverQuery work blocking the foreground queries. Can HKObserverQuery background work get in the way of foreground queries? If so, is there a recommended way to pause or coordinate it when the app becomes active? Thank you
0
1
231
2w
HealthKit Blood Pressure authorization broken on iOS 26.5 RC
Hello, I'm experiencing a bug on iOS 26.5 RC1/RC2 where the Blood Pressure option is silently excluded from the HealthKit permission dialog (when requesting HKQuantityTypeIdentifierBloodPressureSystolic and HKQuantityTypeIdentifierBloodPressureDiastolic). This does not reproduce on iOS 26.4.2 or earlier. What happens: When BP types are requested alone, a blank white modal slides up and immediately dismisses — no permission UI is shown. When BP is requested alongside other types, a normal dialog appears for those other types, but Blood Pressure is simply absent from the list. The completion handler returns success = YES, error = nil in both cases, but BP permission is never granted. The result: Settings → Privacy & Security → Health → [app] shows Blood Pressure as requested but not granted getRequestStatusForAuthorizationToShareTypes for the BP types keeps returning ShouldRequest indefinitely HealthKit queries for BP samples return no data Workaround: Manually toggling Blood Pressure to ON in Settings → Privacy & Security → Health → [app name] fixes everything - queries work, notifications fire, and getRequestStatusForAuthorizationToShareTypes correctly returns HKAuthorizationRequestStatusUnnecessary. Environment: Confirmed broken: iOS 26.5 RC1 (23F75) and RC2 (23F77), iPhone 11; iOS 26.5 RC1 (23F73), simulator Confirmed working: iOS 26.4.2 (device), iOS 26.4.1 (simulator) Feedback filed as FB22735935.
12
11
2.5k
3w
Detecting External Heart Rate Monitor Availability
I've noticed that the Fitness app on the iPhone can rapidly detect the presence of an Apple Watch or External Heart Rate Monitor (e.g., AirPods Pro 3) so that it can adjust the availability of certain exercise types. Is this done through an API that is public? Can third party fitness apps access similar functionality so users can be pre-alerted to the availability of workout types that require a heart rate sensor of some sort?
2
0
434
Jun ’26
Cycling VO2max
Can Apple Watch please add support for cycling VO2max algorithm and tracking? I sheared my meniscus trail running, ending my running career, and I’m solely cycling for cardio now. I’ve now had to adopt a xxxxxx watch which supports cycling VO2max calc and tracking, and I miss my Apple Watch. Enabling BT pairing to a power meter would provide HR-Power-Cadence (or with a head unit synched to a pm ++ Speed and VAM)
4
0
367
Jun ’26
Saving workout routes on the phone when locked
I'm using HKLiveWorkoutDataSource and HKWorkoutRouteBuilder. The running workouts my app supports can be timed or distance-based, so the user may complete the workout while the phone is locked. In this case, the workout route cannot be saved because HealthKit is locked. To work around this issue, I save route data to the device and listen for UIApplication.protectedDataDidBecomeAvailableNotification to later add the route to the workout. Note, this is not needed on the watch, just the phone. Is this limitation by design, or is there a better way to handle it? BTW, thanks for making these APIs available on the phone in iOS 26 and also adding the heart rate zone APIs in 27
3
0
406
Jun ’26
Editing Apple Health Workouts
Sometimes my users would like to update an Apple Health workout after it's been saved. For example, maybe they forgot to end the workout and want to trim it. Or maybe it was a treadmill workout, and they want to add the stats from the treadmill. The way I've attempted to do this in the past is to create a new HKWorkoutBuilder, call beginCollection, and add the data the user wants to keep from the original workout (events, activities, samples, workout route, and metadata with an incremented HKMetadataKeySyncIdentifier. After all that, I call endCollection() and finishWorkout() on the builder. Is this the right way to go about it? For trimming a workout, it would be great to have a way to just duplicate a workout with an adjusted start and end time and have HealthKit do all the hard work of trimming data.
2
0
304
Jun ’26
About measuring running distance in a standard 400m playground
Everyday, when I am running on a standard 400m playground,I suffer that the distance which Apple Watch shows is always about 50m less than the standard 400m. If I run a much longer distance ,the terrible mistake nearly drives me mad. Also, the location the Apple Watch shows is often completely mistaken from the real.In China ,the playground mode still cannot be used, all aspects of the running exercises measuring give us a terrible experience.How could you deal with it and now what methods we have can avoid these problems?!!!
1
0
333
Jun ’26
Track workouts with HealthKit on iOS + GPS tracking
I've built an iOS app according to this WWDC25 video (https://developer.apple.com/videos/play/wwdc2025/322). I added GPS tracking for workouts. In Xcode, I've enabled Signing & Capabilities > Background Modes: Location Updates. And in my code, I request CLAuthorisationStatus.authorizedAlways. Everything works as expected, but I am unsure if .authorizedWhenInUse will not be sufficient for this kind of app. It seems even to work when I use .authorizedWhenInUse as either the Dynamic Island or the Live Activity is shown when the app is not in the foreground. I need clarification by an expert.
Replies
0
Boosts
0
Views
62
Activity
3d
technical clarification on sensorkit measurement sampling
Dear SensorKit team, We are currently working with SensorKit ambient light data under our approved SensorKit entitlement for research use. We would be grateful for some technical clarification on the sampling strategy for the SRSensor.ambientLightSensor stream, as this directly affects how we analyse and report the data. In exported data from Apple Watch, we observe that ambient light samples do not appear to follow a fixed sampling cadence. Instead, the data appear burst-like: in one short window, we see many samples with inter-sample intervals around 100 ms, occasional near-duplicate timestamps, and then gaps of around 10 to 30 seconds with no samples. This suggests that the stream may be adaptive, event-triggered, buffered, or subject to system-level sampling decisions. We also noticed a related discrepancy when comparing the SensorKit ambient light trace with the Health app display for a corresponding Time in Daylight sample. In one example, the Health app shows a 5-minute Time in Daylight interval with a “Maximum Light Intensity” value of 9,493 lux. In the SensorKit ambient light trace around that period, the raw samples show a different maximum depending on the precise time window considered, including higher values shortly before the HealthKit interval start and lower values within the subset of SensorKit samples we inspected. We realise that Time in Daylight may be generated by a separate internal aggregation or classification pipeline, but this comparison raised the question of how closely SensorKit ambient light samples should be expected to correspond to the light intensity values displayed in Health. Could you clarify the following points for SensorKit ambient light data? Is SRSensor.ambientLightSensor sampled at a fixed cadence, or is sampling adaptive / event-driven? If sampling is adaptive, what factors influence sampling density? For example, changes in illuminance, device or wrist motion, device orientation, display state, app state, power state, charging state, or other system-level conditions. Are ambient light readings buffered and delivered or exported in bursts? Do SensorKit timestamps correspond to the physical sensor acquisition time, processing time, or the time at which the sample is made available through SensorKit? Are duplicate or near-duplicate ambient light samples expected in SensorKit exports? Are there circumstances under which ambient light sampling is suspended, downsampled, or suppressed? Is SensorKit ambient light expected to match, approximate, or differ from the light intensity values shown in Health app Time in Daylight sample details? Is the “Maximum Light Intensity” shown for Time in Daylight computed from the same underlying ambient light sensor stream exposed through SensorKit, or from a separate internal stream or aggregation? Are there recommended practices for analysing SensorKit ambient light data, especially with respect to irregular sampling, burst sampling, missing intervals, and aggregation to longer time windows? Is the sampling strategy the same across Apple Watch hardware versions, or should researchers expect device-specific differences? We do not need proprietary implementation details. Our goal is to understand the methodological constraints well enough to analyse the data appropriately and describe the limitations accurately in scientific work. Thank you!
Replies
1
Boosts
0
Views
97
Activity
5d
Dive workout
Hello, How can I read the dive count and total underwater time for a Dive workout from Apple Health? Is this information available through HealthKit, and if so, which APIs or workout metadata keys should I use? Thanks! Stéphane
Replies
2
Boosts
0
Views
107
Activity
6d
Apple Watch awards missing after iPhone iCloud restore
Hello forum-community I hope you're all doing well. My Iphone recently went to apple in order to fix an issue with my camera. After I received it back, I loaded a Backup from ICloud I made before the Iphone went to Apple. So far so good. The Back Up took very long to load onto the device. Especially the apps downloading took almost four hours but I was also fine with that. When the BackUp was finished I had some bugs in some apps like yazio. Some scaling issue led to the app zooming in and out every time I tried to open Yazio. Not really a big deal but it somehow it annoyed me, so I upgraded the Ios from stable 26.5.1 to public beta 26.6 . Enough context. Now my problem: There must have went something wrong while loading the backup. All my workouts from 2023-today, all monthly medals, all other fitness data can be seen in the app. Most medals in the category „workouts“ somehow did NOT sync properly so it looks like I never completed a workout at all. What I've tried so far: Restored both my iPhone and Apple Watch from backups. Verified that all workout history is present (workouts since 2023 are intact). Verified that monthly challenges are still present. Verified that Health data appears complete and correct. Verified that activity data (Move, Exercise, Stand) is present. Confirmed that workout records are correctly stored in the Fitness and Health apps. Updated the iPhone to the latest iOS beta version. Unpaired and re-paired the Apple Watch. Restored the Apple Watch from an older backup. Allowed several days (approximately 5+ days) for Fitness and Health data to resynchronize. Kept both devices connected to Wi-Fi and charging for extended periods. Confirmed that some achievements (e.g. Longest Move Streak) are displayed correctly. Confirmed that many Workout Awards are missing or shown as not earned. Confirmed that some “Close Your Rings” awards are incorrect or missing. Confirmed that awards for workouts already completed after the restore (e.g. Walking Workout, Running Workout) remain greyed out. Confirmed that newly completed qualifying workouts are recorded correctly but do not trigger the corresponding awards. Verified that the issue persists after restoring the Apple Watch from a different backup. Contacted Apple Support. Apple Support declined further troubleshooting because the iPhone is running a beta version of iOS and recommended restoring to a non-beta version (already did that - result: no fitness data at all) Any more suggestions on how to fix this? Thanks everybody!
Replies
1
Boosts
1
Views
256
Activity
1w
Unable to invalidate interval: no data source available error when fetching steps using HKStatisticsCollectionQuery
While attempting to read a user’s daily step history spanning backward to the last 7 days, a small but consistent subset of users encounter Error Code 3 with the underlying error description: Error Code 3 "Unable to invalidate interval: no data source available." When this error occurs, we are entirely unable to read their step history. We have received ~10 direct user reports of this within the last couple of weeks.
Replies
14
Boosts
2
Views
1.3k
Activity
1w
Feature Proposal: Apple Intelligence Guided Workouts for Apple Watch
Hi everyone, After watching WWDC26 and going for a run today, I came up with an idea that I believe could be a natural extension of Apple Intelligence and Apple Watch. This proposal is not intended to replace Custom Workouts. Instead, it focuses on removing the manual setup required to create them by allowing Apple Intelligence to understand workout plans written in natural language. Today, Apple Watch already supports Custom Workouts, but users still have to manually recreate interval workouts. For example: • Walk 5 minutes • Run 1 minute • Walk 1 minute 30 seconds • Repeat 6 times Instead, Apple Intelligence could understand workouts written in natural language and automatically generate a structured Apple Watch workout. This could work from multiple sources: Notes Messages Mail PDFs Screenshots Photos of printed training plans Websites The generated workout could then be reviewed by the user before being saved and synchronized to Apple Watch. Intelligent Haptics I also imagined an optional feature called Intelligent Haptics. Instead of using a single vibration for interval transitions, the watch could communicate through different haptic patterns: Progressive vibration before a running interval starts. Decreasing vibration when an interval ends. Rhythmic vibrations during recovery to help regulate breathing. The goal isn't simply to notify the user—it is to reduce the need to constantly look at the display and allow them to stay focused on the workout. Since Apple Intelligence is becoming a system-wide capability, I think workouts could be understood just like calendar events, reminders or emails. I have already submitted this proposal through Feedback Assistant, but I would love to hear what other developers think. Would this be a feature you would like to see in watchOS? I'm curious to hear how other developers would improve this concept.
Replies
0
Boosts
0
Views
158
Activity
1w
HKStatisticsCollectionQuery initialResultsHandler returns nil results (error) for one specific user — read auth granted, data exists, survives reinstall
Environment: iPhone 13 Pro, iOS 26.5. Affects a single user out of many; cannot reproduce on any of our test devices. We use HKStatisticsCollectionQuery to read step counts for a statistics screen. For one specific user, the query's initialResultsHandler appears to deliver results == nil (the success branch never runs), so our completion is never called and the screen shows an infinite spinner. private let store = HKHealthStore() func fetchHourlyStepCounts(for day: Date, completion: @escaping ([Int]) -> Void) { guard let stepType = HKQuantityType.quantityType(forIdentifier: .stepCount) else { return } let calendar = Calendar.current let startOfDay = calendar.startOfDay(for: day) var hourly = DateComponents() hourly.hour = 1 let query = HKStatisticsCollectionQuery( quantityType: stepType, quantitySamplePredicate: nil, options: .cumulativeSum, anchorDate: startOfDay, intervalComponents: hourly ) query.initialResultsHandler = { _, collection, error in guard let collection else { // For the affected user, execution seems to reach here (collection == nil). // Adding logging of the HKError + authorization status for the next occurrence. return } var counts: [Int] = [] let end = calendar.date(byAdding: .day, value: 1, to: startOfDay)! collection.enumerateStatistics(from: startOfDay, to: end) { stats, _ in let steps = stats.sumQuantity()?.doubleValue(for: .count()) ?? 0 counts.append(Int(steps)) } DispatchQueue.main.async { completion(counts) } } store.execute(query) } What we've confirmed / ruled out: Read authorization for stepCount is granted (the user toggled it ON in the HealthKit sheet on video). The Apple Health app shows step data for this user (so data exists). A coarser query (2-year interval) for the same user succeeds, while the hourly query appears to fail — same type / predicate / options / auth. Symptom persists across app reinstall and device reboot, and re-granting Health permission. Permission denial returns empty results (per Apple docs), not an error — so this isn't simple denial. Not errorDatabaseInaccessible as far as we can tell (foreground, device unlocked). Questions: What can cause HKStatisticsCollectionQuery.initialResultsHandler to return results == nil (with an error) persistently for one device/account, when read auth is granted and data exists? Can errorHealthDataRestricted occur without an MDM/supervised profile (i.e., on a normal consumer device)? What device/account states actually trigger it? Is it expected that a coarse-interval query succeeds while an hourly-interval query on the same type fails for the same user? We're adding logging of the actual HKError code + authorizationStatus for the next occurrence, but would appreciate any insight on what conditions produce this.
Replies
0
Boosts
0
Views
177
Activity
1w
Why does a watchOS HKLiveWorkoutBuilder soccer workout report shorter totalDistance than Apple Workout soccer?
I’m developing a watchOS app that records outdoor soccer workouts using HealthKit. My app starts a workout session with: HKWorkoutConfiguration.activityType = .soccer HKWorkoutConfiguration.locationType = .outdoor HKWorkoutSession HKLiveWorkoutBuilder HKLiveWorkoutDataSource During the workout, I display distance from the live builder statistics: HKQuantityType.quantityType(forIdentifier: .distanceWalkingRunning) After the workout ends, I save the workout using finishWorkout(), and later read the saved distance from: HKWorkout.totalDistance?.doubleValue(for: .meter()) So the total distance shown in my app is not calculated manually from GPS route points. It comes from HealthKit’s workout distance. I noticed a difference between soccer workouts recorded by Apple’s built-in Workout app and soccer workouts recorded by my third-party watchOS app. Example comparison: Apple Workout app soccer: Active duration: about 88 min Steps: about 8,832 Distance: about 6.7 km No visible route/location data in Fitness My watchOS app soccer: Active duration: about 87 min Steps: about 8,998 Distance: about 5.6 km Includes route/location data Workout recorded through HKWorkoutSession + HKLiveWorkoutBuilder Distance read from HKWorkout.totalDistance The step counts and active durations are very close, but the distance differs by about 1.1 km. One important detail is that the Apple Workout app soccer workout does not appear to include visible route/location data in Fitness, while my third-party workout does include route/location data. Despite that, the Apple Workout app reports a longer distance. So the comparison is not simply “GPS route distance vs GPS route distance”. It looks like the built-in Workout app may be estimating soccer distance without exposing route data, while HKLiveWorkoutBuilder for a third-party .soccer workout may be producing a different totalDistance estimate. My questions are: When the built-in Apple Workout app records an outdoor soccer workout without exposing route data, how is totalDistance estimated? Is that distance estimation behavior available to third-party watchOS apps using HKWorkoutSession + HKLiveWorkoutBuilder with .soccer? If a third-party app records route data for the same soccer activity, can that change how HealthKit calculates totalDistance compared with a no-route built-in Workout app recording? For third-party soccer workouts, should developers expect HKWorkout.totalDistance to match the built-in Workout app, or is a difference expected? Is there any additional configuration, entitlement, data type, or best practice required to get more accurate distance estimates for soccer workouts? Any clarification on the expected behavior would be very helpful. Thanks!
Replies
0
Boosts
1
Views
264
Activity
2w
WorkoutKit Feature Request: Distance & Time based IntervalBlock
Today, IntervalBlock only supports a fixed iteration count: IntervalBlock(steps: [IntervalStep], iterations: Int) This works well when the athlete knows exactly how many rounds they want to perform, but a lot of structured running and cycling workouts terminate a repeating block based on cumulative distance or cumulative elapsed time instead. These constructs are first-class on Garmin Connect, TrainingPeaks, FinalSurge, and similar platforms, but there's no way to express them in WorkoutKit's CustomWorkout. We've had to either fall back to a fixed iteration count (which forces us to guess the user's pace) or skip Apple Workout scheduling for these workouts entirely, which is a poor experience for athletes on watchOS. Proposal: // Today (still supported) IntervalBlock(steps: steps, iterations: 5) // Proposed IntervalBlock(steps: steps, until: .distance(5, .kilometers)) IntervalBlock(steps: steps, until: .time(30, .minutes)) IntervalBlock(steps: steps, iterations: 8) // unchanged Example Workouts with proposed features: "Run/walk until 5 km" Run for a minute, then walk for 30 seconds until completing a 5K. "30-minute fartlek" Repeat a hard/easy pair until cumulative time hits 30 min "10 km tempo with surges" Surge/recover until total distance hits 10 km. FB: FB23359408
Replies
0
Boosts
0
Views
220
Activity
2w
Apple Watch awards missing after iPhone iCloud restore
Hello forum-community I hope you're all doing well. My Iphone recently went to apple in order to fix an issue with my camera. After I received it back, I loaded a Backup from ICloud I made before the Iphone went to Apple. So far so good. The Back Up took very long to load onto the device. Especially the apps downloading took almost four hours but I was also fine with that. When the BackUp was finished I had some bugs in some apps like yazio. Some scaling issue led to the app zooming in and out every time I tried to open Yazio. Not really a big deal but it somehow it annoyed me, so I upgraded the Ios from stable 26.5.1 to public beta 26.6 . Enough context. Now my problem: There must have went something wrong while loading the backup. All my workouts from 2023-today, all monthly medals, all other fitness data can be seen in the app. Most medals in the category „workouts“ somehow did NOT sync properly so it looks like I never completed a workout at all. What I've tried so far: Restored both my iPhone and Apple Watch from backups. Verified that all workout history is present (workouts since 2023 are intact). Verified that monthly challenges are still present. Verified that Health data appears complete and correct. Verified that activity data (Move, Exercise, Stand) is present. Confirmed that workout records are correctly stored in the Fitness and Health apps. Updated the iPhone to the latest iOS beta version. Unpaired and re-paired the Apple Watch. Restored the Apple Watch from an older backup. Allowed several days (approximately 5+ days) for Fitness and Health data to resynchronize. Kept both devices connected to Wi-Fi and charging for extended periods. Confirmed that some achievements (e.g. Longest Move Streak) are displayed correctly. Confirmed that many Workout Awards are missing or shown as not earned. Confirmed that some “Close Your Rings” awards are incorrect or missing. Confirmed that awards for workouts already completed after the restore (e.g. Walking Workout, Running Workout) remain greyed out. Confirmed that newly completed qualifying workouts are recorded correctly but do not trigger the corresponding awards. Verified that the issue persists after restoring the Apple Watch from a different backup. Contacted Apple Support. Apple Support declined further troubleshooting because the iPhone is running a beta version of iOS and recommended restoring to a non-beta version (already did that - result: no fitness data at all) (Device iPhone 17 Pro Max - Apple Watch Series 9) Any more suggestions on how to fix this? Thanks everybody!
Replies
5
Boosts
0
Views
269
Activity
2w
HealthKit multiple queries performance questions
We're building two apps that rely almost exclusively on HealthKit, so we run a high volume of queries against a single shared HKHealthStore — mostly HKSampleQuery, plus HKStatisticsQuery and HKQuantitySeriesSampleQuery where needed. We also use HKObserverQuery for background processing and widget updates. The data is sleep, body metrics, and workouts. As our feature set grew, so did data-loading time, to the point of being a noticeable annoyance for users. To speed things up we moved from serial to concurrent queries. Mechanism: we issue the batch via a ThrowingTaskGroup — each child task calls execute() and awaits the completion handler through a continuation — with up to ~30 queries in flight concurrently against the one shared store. Symptom: The app doesn't freeze and the queries start fine, but their results sometimes take 30s+ to come back. Most of the times the same data fetch takes only a couple of seconds. There's no clear pattern except that it happens far more often on foregrounding. Environment: Devices we use for testing are iPhone 17 Pro and iPhone 15 pro both running iOS 26.5. Since the symptoms are hard to catch we're using text file logging to time the data layer responses. We're considering bounding concurrency to a small N via a capped task group, or reverting to serial — but both feel like either a regression or added complexity we can't justify without understanding the real cause. Questions: When we start ~30 queries at once against a single HKHealthStore, does HealthKit actually run them in parallel, or do they get handled one-at-a-time (or rate-limited) behind the scenes? Is there a sensible upper limit on how many queries we should run at once? Should we cap it to a small number, or does that not help because the system serializes them anyway? (Also: is sharing one HKHealthStore across the app the right approach?) Why would this happen mainly when the app comes to the foreground? A few possibilities we'd like confirmed or ruled out: the device hasn't been unlocked yet so health data isn't available, the connection to the HealthKit service is being re-established after backgrounding, general contention, or our background HKObserverQuery work blocking the foreground queries. Can HKObserverQuery background work get in the way of foreground queries? If so, is there a recommended way to pause or coordinate it when the app becomes active? Thank you
Replies
0
Boosts
1
Views
231
Activity
2w
HealthKit Blood Pressure authorization broken on iOS 26.5 RC
Hello, I'm experiencing a bug on iOS 26.5 RC1/RC2 where the Blood Pressure option is silently excluded from the HealthKit permission dialog (when requesting HKQuantityTypeIdentifierBloodPressureSystolic and HKQuantityTypeIdentifierBloodPressureDiastolic). This does not reproduce on iOS 26.4.2 or earlier. What happens: When BP types are requested alone, a blank white modal slides up and immediately dismisses — no permission UI is shown. When BP is requested alongside other types, a normal dialog appears for those other types, but Blood Pressure is simply absent from the list. The completion handler returns success = YES, error = nil in both cases, but BP permission is never granted. The result: Settings → Privacy & Security → Health → [app] shows Blood Pressure as requested but not granted getRequestStatusForAuthorizationToShareTypes for the BP types keeps returning ShouldRequest indefinitely HealthKit queries for BP samples return no data Workaround: Manually toggling Blood Pressure to ON in Settings → Privacy & Security → Health → [app name] fixes everything - queries work, notifications fire, and getRequestStatusForAuthorizationToShareTypes correctly returns HKAuthorizationRequestStatusUnnecessary. Environment: Confirmed broken: iOS 26.5 RC1 (23F75) and RC2 (23F77), iPhone 11; iOS 26.5 RC1 (23F73), simulator Confirmed working: iOS 26.4.2 (device), iOS 26.4.1 (simulator) Feedback filed as FB22735935.
Replies
12
Boosts
11
Views
2.5k
Activity
3w
Detecting user wakeup from Apple WatchOS 27
Does Apple WatchOS 27 support my iOS 27 app being notified when the user wakes up?
Replies
1
Boosts
0
Views
424
Activity
4w
Detecting External Heart Rate Monitor Availability
I've noticed that the Fitness app on the iPhone can rapidly detect the presence of an Apple Watch or External Heart Rate Monitor (e.g., AirPods Pro 3) so that it can adjust the availability of certain exercise types. Is this done through an API that is public? Can third party fitness apps access similar functionality so users can be pre-alerted to the availability of workout types that require a heart rate sensor of some sort?
Replies
2
Boosts
0
Views
434
Activity
Jun ’26
Cycling VO2max
Can Apple Watch please add support for cycling VO2max algorithm and tracking? I sheared my meniscus trail running, ending my running career, and I’m solely cycling for cardio now. I’ve now had to adopt a xxxxxx watch which supports cycling VO2max calc and tracking, and I miss my Apple Watch. Enabling BT pairing to a power meter would provide HR-Power-Cadence (or with a head unit synched to a pm ++ Speed and VAM)
Replies
4
Boosts
0
Views
367
Activity
Jun ’26
Saving workout routes on the phone when locked
I'm using HKLiveWorkoutDataSource and HKWorkoutRouteBuilder. The running workouts my app supports can be timed or distance-based, so the user may complete the workout while the phone is locked. In this case, the workout route cannot be saved because HealthKit is locked. To work around this issue, I save route data to the device and listen for UIApplication.protectedDataDidBecomeAvailableNotification to later add the route to the workout. Note, this is not needed on the watch, just the phone. Is this limitation by design, or is there a better way to handle it? BTW, thanks for making these APIs available on the phone in iOS 26 and also adding the heart rate zone APIs in 27
Replies
3
Boosts
0
Views
406
Activity
Jun ’26
Editing Apple Health Workouts
Sometimes my users would like to update an Apple Health workout after it's been saved. For example, maybe they forgot to end the workout and want to trim it. Or maybe it was a treadmill workout, and they want to add the stats from the treadmill. The way I've attempted to do this in the past is to create a new HKWorkoutBuilder, call beginCollection, and add the data the user wants to keep from the original workout (events, activities, samples, workout route, and metadata with an incremented HKMetadataKeySyncIdentifier. After all that, I call endCollection() and finishWorkout() on the builder. Is this the right way to go about it? For trimming a workout, it would be great to have a way to just duplicate a workout with an adjusted start and end time and have HealthKit do all the hard work of trimming data.
Replies
2
Boosts
0
Views
304
Activity
Jun ’26
BGHealthResearchTaskRequest beyond Health Research apps
Please could you give access to BGHealthResearchTaskRequest beyond Health Research apps. I can't see any rational why this API is restricted to Health Research apps. Without it, it is impossible to provide a decent UX based on historical data. Thanks, Stéphane FB22560687
Replies
3
Boosts
0
Views
333
Activity
Jun ’26
iOS kills the app while HKObserverQuery in background
Time to time, my app is killed in the background while handling HKObserverQuery. I always call the completion handler using a defer handler. It looks like I query a lot of data in the background. Can this be a reason for background termination, and how to handle it gracefully?
Replies
1
Boosts
1
Views
362
Activity
Jun ’26
About measuring running distance in a standard 400m playground
Everyday, when I am running on a standard 400m playground,I suffer that the distance which Apple Watch shows is always about 50m less than the standard 400m. If I run a much longer distance ,the terrible mistake nearly drives me mad. Also, the location the Apple Watch shows is often completely mistaken from the real.In China ,the playground mode still cannot be used, all aspects of the running exercises measuring give us a terrible experience.How could you deal with it and now what methods we have can avoid these problems?!!!
Replies
1
Boosts
0
Views
333
Activity
Jun ’26