Health and Fitness

RSS for tag

Use HealthKit to enable your iOS and watchOS apps to work with the Apple Health app.

Posts under Health and Fitness tag

200 Posts

Post

Replies

Boosts

Views

Activity

How does the Health app reconcile overlapping sleep samples written to HealthKit?
I'm trying to understand the exact rules the Health app uses to reconcile (deduplicate/merge/discard) overlapping sleep samples, and I'm hoping an Apple engineer can clarify the behavior. Background: My Apple Watch wrote sleep samples to HealthKit twice within the same day, and the two writes overlap substantially: Same stage, overlapping in time — e.g., two "Core" sleep samples that overlap each other in time. Different stages, overlapping in time — e.g., Deep and Core overlap, and Core and REM (Rapid Eye Movement) also overlap. Observation: Even though the raw samples contain these overlaps, the Health app ultimately displays non-overlapping data (i.e., it has reconciled the overlaps somehow). I'm confused about the exact reconciliation rules the Health app applies to such overlapping data. To make the problem clearer, I've visualized the raw HealthKit samples. In the attached chart, you can see the same stage was written multiple times at different timestamps, shown in chronological order. However, the data ultimately displayed by the Health app differs significantly from the raw data — samples appear to have been reconciled, dropped, and merged in various ways. Question: What are the detailed rules the Health app uses to reconcile overlapping sleep samples? Specifically: When samples of the same stage overlap in time, how is the overlap resolved? When samples of different stages overlap in time, which stage takes precedence, and how are the boundaries adjusted? Are samples merged, truncated, or discarded entirely? Under what conditions? Any clarification from the HealthKit team would be greatly appreciated. Appendix 1 — Raw data visualization. All sleep samples as shown in the Health app (source: the complete sleep dataset in the Health app). Appendix 2 — Final presentation. How the Health app presents the data after reconciling the raw samples. Note — Comparing Appendix 2 with Appendix 1, the following differences are clearly visible: 1.A portion of Deep sleep was discarded. 2.Four awake segments were discarded. 3.Multiple REM segments were also discarded. 4.Core sleep was partially merged.
1
0
39
1d
App submission in "Waiting for review" since 9th August (12 days)
Hello, I submitted our app to the App Store on 9th august and it has been stuck in "Waiting for review". We have a very critical launch date timeline. We have to release our app in the first week of September (before 5th); therefore, we submitted it quite early. But seems like the app is stuck indefinitely in the "Waiting for review" state. We even raised a support ticket for this. No response on that too. App ID: 6799395555 Support conversation ID: 20000139951347 What can be done to expedite this as further delays will cause us to miss our timeline?
0
0
29
1d
Intermittent missing historical step counts from HKStatisticsCollectionQuery on iOS 27 beta
Hello, We received a customer report about intermittent missing historical step-count data when using HKStatisticsCollectionQuery on iOS 27 beta. When the query was executed on August 16, only the most recent two days—August 16 and August 15—returned correct step counts. Earlier dates returned nil from sumQuantity() and were consequently treated as zero. However, queries executed on August 14 and August 18 returned the expected data. Therefore, the problem appears to be intermittent rather than consistently reproducible. The customer confirmed that all affected historical step counts were visible in the Apple Health app, including the dates returned as zero by our query. We have not received the same type of customer report from devices running iOS 26 or earlier. Here is a simplified version of our query: guard let stepType = HKObjectType.quantityType( forIdentifier: .stepCount ) else { return } var calendar = Calendar(identifier: .gregorian) calendar.timeZone = TimeZone(identifier: "Asia/Seoul")! let queryStartDate = calendar.startOfDay(for: parsedStartDate) let tomorrow = calendar.date(byAdding: .day, value: 1, to: Date())! let queryEndDate = calendar.startOfDay(for: tomorrow) let datePredicate = HKQuery.predicateForSamples( withStart: queryStartDate, end: queryEndDate, options: .strictStartDate ) let nonUserEnteredPredicate = HKQuery.predicateForObjects( withMetadataKey: HKMetadataKeyWasUserEntered, operatorType: .notEqualTo, value: NSNumber(value: true) ) let predicate = NSCompoundPredicate( andPredicateWithSubpredicates: [ datePredicate, nonUserEnteredPredicate ] ) let anchorDate = calendar.startOfDay(for: Date()) var interval = DateComponents() interval.day = 1 let query = HKStatisticsCollectionQuery( quantityType: stepType, quantitySamplePredicate: predicate, options: .cumulativeSum, anchorDate: anchorDate, intervalComponents: interval ) query.initialResultsHandler = { _, results, error in guard let results, error == nil else { print("Query error: \(String(describing: error))") return } results.enumerateStatistics( from: queryStartDate, to: queryEndDate ) { statistics, _ in let steps = statistics .sumQuantity()? .doubleValue(for: .count()) ?? 0 print(statistics.startDate, statistics.endDate, steps) } } healthStore.execute(query) Observed behavior Query executed on August 14: historical step counts returned correctly Query executed on August 16: August 16 and August 15 returned correctly August 14 and earlier returned nil from sumQuantity() Query executed on August 18: historical step counts returned correctly again No query error was reported All step counts remained visible in the customer's Apple Health app Expected behavior The query should consistently return cumulative daily step counts when matching HealthKit samples exist and are visible in the Health app. Because this was reported through customer support, we do not currently know the exact iOS 27 beta build number. We are also unable to reproduce it consistently on our own test devices. Questions Is there a known intermittent issue with historical .stepCount queries on iOS 27 beta? Can HealthKit temporarily return incomplete statistics while data is being indexed, synchronized, or migrated? Is there a recommended way to detect that the returned statistics are temporarily incomplete? Should applications retry the query when older statistics unexpectedly return nil without an error? We have not received reports of this behavior from customers using iOS 26 or earlier. Thank you.
1
0
54
2d
iOS 27 Health permissions: a reckoning is coming
iOS 27 adds a second stage to HealthKit read authorization. After picking data types, the user chooses "Past 30 Days and Future Data" or "All Recorded Data and Future Data", with Allow disabled until one is selected. Every user of every health app now makes this call, in the first seconds of onboarding, with no real context about what the app needs. I don't think the scale of this has landed yet. A meaningful share of users will pick 30 days. multi-year health trends, month to month comparisons, all-time records: with 30 days these features don't get worse, they stop existing. And it breaks silently. The user sees empty charts and a app that doesn't do what the screenshots promised. They won't connect that to a sheet they tapped through on day one — they'll connect it to the app. That's the reckoning: a wave of one-star reviews and support mail for a decision the developer never saw and can't inspect. Because we can't inspect it .authorizationStatus(for:) deliberately hides read authorization and getRequestStatusForAuthorization only says whether prompting would show UI, so a 30-day grant and a genuinely new Apple Watch user look identical from the query layer. A callback when Health permissions change for a type — even without disclosing the new state — would go a long way here. And we can't route users to the fix. UIApplication.openSettingsURLString opens the app's own Settings page, which has no Health section. The real control sits at Settings › Privacy & Security › Health › — four levels deep, unreachable from any public API. My suggestion is a URL constant scoped to the calling app, the way openNotificationSettingsURLString (iOS 15.4+) and openDefaultApplicationsSettingsURLString (iOS 18.3+) already work. But that's just my idea; if there's a better mitigation, or something already planned, I'd like to hear it. Worth saying the privacy gain looks thin either way: the app keeps all future data indefinitely, so a 30-day grant becomes a full-history grant in thirty days for anyone who keeps the app. The window limits what's readable today, not what accumulates. iOS 27 release is approaching... I think this will cause problems 😞 Filed as FB24398048 and FB24398031
0
0
104
4d
Background Health Store Access for Lock Screen Widgets
It's fairly well know and stated that the Apple Health / HealthKit data store is unavailable when iPhone is locked. Since Lock Screen Widgets were introduced there's been a feature parity mismatch with Apple's own Fitness app which is able to display updating Activity Rings on the Lock Screen. Third party apps cannot do this and have to rely unlocking their device to then trigger an update. This means they often display stale and wrong Health data. With the release of iOS 18 beta, I see no changes to this... Is there anything I've missed? Currently for requesting the Timeline Updates on my Widget I have to just keep requesting updates as often as possible and hope that each time the iPhone might be unlocked.... This is inefficient and a waste of device resources. Even a Widget timeline reload API that let the developer say "Only call update if iPhone unlocked" would be useful.
4
1
1.8k
2w
Extended Runtime API - Health Monitoring
In the WWDC 2019 session "Extended Runtime for WatchOS apps" the video talks about an entitlement being required to use the HR sensor judiciously in the background. It provides a link to request the entitlement which no longer works: http://developer.apple.com/contect/request/health-monitoring The session video is also quite hard to find these days. Does anyone know why this is the case? Is the API and entitlement still available? Is there a supported way to run, even periodically, in the background on the Watch app (ignoring the background observer route which is known to be unreliable) and access existing HR sensor data
15
1
2.1k
2w
Beta testers wanted: Somataquest — personalized training and recovery insights
I’m looking for about 15 additional iPhone/iWatch users to test SomataQuest, an early-stage fitness app that uses Apple Health data to help users understand their recent training, recovery, and readiness for today’s activity. Learn more: https://www.nexuspointinnovations.com/somataquest TestFlight: https://testflight.apple.com/join/BjXUh9bj I’d especially appreciate testers trying the following: Connect Apple Health and complete the initial setup Check whether the readiness score and its explanation make sense Review whether the app represents your recent workouts and activity accurately Evaluate whether the suggested training intensity feels reasonable Report anything confusing, incorrect, slow, or broken The app currently works best for people who regularly record workouts, sleep, heart-rate, or activity data in Apple Health. Feedback can be submitted through TestFlight or posted in this thread. This is an early beta, so candid feedback—especially about what is unclear or not useful—is very welcome.
0
0
267
3w
Guideline 5.1.3(ii) — does encrypted, per-user private CloudKit storage count as "storing personal health information in iCloud"?
Guideline 5.1.3(ii) says apps "may not store personal health information in iCloud." Does this apply to any use of a private, per-user CloudKit database for health-related data, or is it specifically about unencrypted/shared storage, or data sourced from HealthKit? If a health app end-to-end encrypts sensitive fields so that even Apple's infrastructure can't read them, and the data never leaves the individual user's own iCloud account, does that change how 5.1.3(ii) applies — or is the guideline a blanket restriction regardless of encryption? Has anyone gotten reviewer feedback (approval or rejection) that clarifies how this is actually enforced in practice? Thanks in advance!
1
0
371
Jul ’26
HKStatisticsCollectionQueryDescriptor intermittently returns no data for certain date ranges on iOS 27
We are seeing inconsistent results from HKStatisticsCollectionQueryDescriptor on iOS 27. Using the same quantity type, statistics options, anchor date, interval components, and predicate configuration, some date ranges return the expected statistics, while other ranges unexpectedly return empty results or buckets with no quantity. The affected ranges do contain HealthKit samples: HKSampleQueryDescriptor finds samples in the same date range. HKStatisticsQueryDescriptor returns the expected value when run separately for an affected bucket. HKStatisticsCollectionQueryDescriptor returns no quantity for that same bucket. Slightly expanding or shifting the date range may cause the collection query to return data again. A simplified version of the query looks like this: let datePredicate = HKQuery.predicateForSamples( withStart: startDate, end: endDate, options: .strictStartDate ) let descriptor = HKStatisticsCollectionQueryDescriptor( predicate: .quantitySample( type: quantityType, predicate: datePredicate ), options: .cumulativeSum, anchorDate: anchorDate, intervalComponents: DateComponents(day: 1) ) let collection = try await descriptor.result(for: healthStore) collection.enumerateStatistics(from: startDate, to: endDate) { statistics, _ in let quantity = statistics.sumQuantity() print(statistics.startDate, quantity as Any) } Expected behavior Every interval containing matching samples should return the corresponding statistics, regardless of the overall requested date range. Actual behavior Some date ranges produce missing or empty buckets even though matching samples exist and an individual HKStatisticsQueryDescriptor can calculate the expected value. Changing only the date range can make the data appear or disappear. The samples are visible to the app in the affected range, so this does not appear to be explained solely by iOS 27’s Limited History authorization. This behavior was not observed with the same query flow on earlier iOS versions. Is this a known regression in HKStatisticsCollectionQueryDescriptor on iOS 27, or has the expected date-range or predicate behavior changed?
0
0
457
Jul ’26
HKWorkoutBuilder.finishWorkout intermittently returns nil workout and nil error while samples are successfully saved (iOS 26.4–27)
We're seeing an intermittent issue with HKWorkoutBuilder.finishWorkout() in our production app. Our workflow is: builder.beginCollection(withStart: start) { success, error in guard success else { return } let authorizedSamples = samples.filter { self.healthStore.authorizationStatus(for: $0.quantityType) == .sharingAuthorized } builder.add(authorizedSamples) { success, error in guard success else { return } builder.endCollection(withEnd: end) { success, error in guard success else { return } builder.finishWorkout { workout, error in print("workout = \(String(describing: workout))") print("error = \(String(describing: error))") } } } } The logs from affected users are: workout builder begin: result: true, error: nil authorized samples: - HKQuantityTypeIdentifierActiveEnergyBurned - HKQuantityTypeIdentifierDistanceWalkingRunning - HKQuantityTypeIdentifierStepCount workout builder add samples: result: true, error: nil workout builder end: result: true, error: nil workout builder finish: workout: nil, error: nil Result The quantity samples (active energy, distance, step count, etc.) are successfully written to Apple Health. However, no HKWorkout is created. Querying HealthKit immediately afterward also confirms that no HKWorkout exists for the corresponding time range. As a result: The workout does not appear in the Fitness app. It does not contribute to Activity Rings. The quantity samples are visible, but there is no associated workout. Environment We've received reports from multiple users on: iOS 26.4 iOS 26.5 iOS 26.6 iOS 27 beta The issue only affects a small percentage of users. The vast majority complete successfully using exactly the same code path. Things we've verified We've ruled out several common causes: The app is in the foreground (UIApplication.shared.applicationState == .active). The device is unlocked. All HealthKit write permissions have been granted. finishWorkout() is called immediately after endCollection() completes. The quantity samples are successfully saved. Querying HealthKit afterward confirms that the HKWorkout itself was never created. This appears to be different from the documented "device locked" behavior, since the device is unlocked and active when the issue occurs. We also found a related discussion: https://developer.apple.com/forums/thread/825838 In that thread, the issue seems to be related to a locked device. However, our issue also occurs while the device is unlocked and the app remains active. Has anyone experienced similar behavior? Have you found any workaround? Has Apple provided any update through Feedback Assistant or DTS? Has anyone successfully recovered from this state by retrying finishWorkout() or using another approach? We're happy to provide additional logs or a minimal reproducible example if that would be helpful.
0
0
444
Jul ’26
Custom Exported Workout missing workoutPlan identifier / Metadata only on the very first app launch/install
Hello everyone, I am experiencing a strange issue regarding retrieving a custom tracking identifier (workoutPlan identifier) from a custom exported workout that has been imported via HealthKit. The Issue: First Fresh Install: When the app is installed for the first time and initialized, it fails to load/fetch the workout plan ID from the imported workout. Subsequent Launches / Re-installs: If I close and relaunch the app, the app successfully fetches the workout plan ID from HealthKit with absolutely no problems. Has anyone found a clean way to handle this without forcing a manual user refresh or an awkward delay/retry mechanism on the first launch? Any insight, workarounds, or best practices would be greatly appreciated! Environment: iOS 17+, Swift, HealthKit
3
0
552
Jul ’26
Custom Exported Workout missing workoutPlan identifier / Metadata only on the very first app launch/install
Hello everyone, I am experiencing a strange issue regarding retrieving a custom tracking identifier (workoutPlan identifier) from a custom exported workout that has been imported via HealthKit. The Issue: First Fresh Install: When the app is installed for the first time and initialized, it fails to load/fetch the workout plan ID from the imported workout. Subsequent Launches / Re-installs: If I close and relaunch the app, the app successfully fetches the workout plan ID from HealthKit with absolutely no problems. Has anyone found a clean way to handle this without forcing a manual user refresh or an awkward delay/retry mechanism on the first launch? Any insight, workarounds, or best practices would be greatly appreciated! Environment: iOS 17+, Swift, HealthKit
1
0
400
Jul ’26
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
591
Jul ’26
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
549
Jun ’26
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
774
Jun ’26
Health permissions problem with watchOS 10.6.2
In the last few weeks 5 users have reported my workout watch app being unable to read health data despite the permissions being enabled in the iPhone Settings app. This has been a common complaint over the years and is usually fixed by disabling the permissions; rebooting both devices; and then enabling them again. This usually nudges iOS into sending the permissions to watchOS. However that procedure doesn't work for these users, all of whom are using watchOS 10.6.2. They are using various versions of iOS 18 or 26 so it seems to be a problem with that version of watchOS, which users are usually limited to because their hardware won't support anything more up to date. It seems that unpairing and re-pairing the watch can fix the problem but not always. I looked around and it seems that other apps are having the same problem: https://www.reddit.com/r/runna/comments/1rhhs2n/runna_wont_start_an_outdoor_run_on_apple_watch/ Does anyone know a way to fix this? My current advice is to repeatedly unpair / re-pair until it works, which isn't really practical! Thanks in advance.
3
0
983
Jun ’26
Indoor workout location
In the Fitness app under iOS 26, each workout location is displayed on a small map. For workouts with routes, I can already successfully read out the route and thus also determine the starting point. So that works. For indoor workouts such as yoga or indoor rowing, the exact location is also displayed in the Fitness app. I would now also like to read out this location for these indoor workouts in my app. Does anyone know how to do this?
1
0
659
May ’26
How does the Health app reconcile overlapping sleep samples written to HealthKit?
I'm trying to understand the exact rules the Health app uses to reconcile (deduplicate/merge/discard) overlapping sleep samples, and I'm hoping an Apple engineer can clarify the behavior. Background: My Apple Watch wrote sleep samples to HealthKit twice within the same day, and the two writes overlap substantially: Same stage, overlapping in time — e.g., two "Core" sleep samples that overlap each other in time. Different stages, overlapping in time — e.g., Deep and Core overlap, and Core and REM (Rapid Eye Movement) also overlap. Observation: Even though the raw samples contain these overlaps, the Health app ultimately displays non-overlapping data (i.e., it has reconciled the overlaps somehow). I'm confused about the exact reconciliation rules the Health app applies to such overlapping data. To make the problem clearer, I've visualized the raw HealthKit samples. In the attached chart, you can see the same stage was written multiple times at different timestamps, shown in chronological order. However, the data ultimately displayed by the Health app differs significantly from the raw data — samples appear to have been reconciled, dropped, and merged in various ways. Question: What are the detailed rules the Health app uses to reconcile overlapping sleep samples? Specifically: When samples of the same stage overlap in time, how is the overlap resolved? When samples of different stages overlap in time, which stage takes precedence, and how are the boundaries adjusted? Are samples merged, truncated, or discarded entirely? Under what conditions? Any clarification from the HealthKit team would be greatly appreciated. Appendix 1 — Raw data visualization. All sleep samples as shown in the Health app (source: the complete sleep dataset in the Health app). Appendix 2 — Final presentation. How the Health app presents the data after reconciling the raw samples. Note — Comparing Appendix 2 with Appendix 1, the following differences are clearly visible: 1.A portion of Deep sleep was discarded. 2.Four awake segments were discarded. 3.Multiple REM segments were also discarded. 4.Core sleep was partially merged.
Replies
1
Boosts
0
Views
39
Activity
1d
App submission in "Waiting for review" since 9th August (12 days)
Hello, I submitted our app to the App Store on 9th august and it has been stuck in "Waiting for review". We have a very critical launch date timeline. We have to release our app in the first week of September (before 5th); therefore, we submitted it quite early. But seems like the app is stuck indefinitely in the "Waiting for review" state. We even raised a support ticket for this. No response on that too. App ID: 6799395555 Support conversation ID: 20000139951347 What can be done to expedite this as further delays will cause us to miss our timeline?
Replies
0
Boosts
0
Views
29
Activity
1d
Intermittent missing historical step counts from HKStatisticsCollectionQuery on iOS 27 beta
Hello, We received a customer report about intermittent missing historical step-count data when using HKStatisticsCollectionQuery on iOS 27 beta. When the query was executed on August 16, only the most recent two days—August 16 and August 15—returned correct step counts. Earlier dates returned nil from sumQuantity() and were consequently treated as zero. However, queries executed on August 14 and August 18 returned the expected data. Therefore, the problem appears to be intermittent rather than consistently reproducible. The customer confirmed that all affected historical step counts were visible in the Apple Health app, including the dates returned as zero by our query. We have not received the same type of customer report from devices running iOS 26 or earlier. Here is a simplified version of our query: guard let stepType = HKObjectType.quantityType( forIdentifier: .stepCount ) else { return } var calendar = Calendar(identifier: .gregorian) calendar.timeZone = TimeZone(identifier: "Asia/Seoul")! let queryStartDate = calendar.startOfDay(for: parsedStartDate) let tomorrow = calendar.date(byAdding: .day, value: 1, to: Date())! let queryEndDate = calendar.startOfDay(for: tomorrow) let datePredicate = HKQuery.predicateForSamples( withStart: queryStartDate, end: queryEndDate, options: .strictStartDate ) let nonUserEnteredPredicate = HKQuery.predicateForObjects( withMetadataKey: HKMetadataKeyWasUserEntered, operatorType: .notEqualTo, value: NSNumber(value: true) ) let predicate = NSCompoundPredicate( andPredicateWithSubpredicates: [ datePredicate, nonUserEnteredPredicate ] ) let anchorDate = calendar.startOfDay(for: Date()) var interval = DateComponents() interval.day = 1 let query = HKStatisticsCollectionQuery( quantityType: stepType, quantitySamplePredicate: predicate, options: .cumulativeSum, anchorDate: anchorDate, intervalComponents: interval ) query.initialResultsHandler = { _, results, error in guard let results, error == nil else { print("Query error: \(String(describing: error))") return } results.enumerateStatistics( from: queryStartDate, to: queryEndDate ) { statistics, _ in let steps = statistics .sumQuantity()? .doubleValue(for: .count()) ?? 0 print(statistics.startDate, statistics.endDate, steps) } } healthStore.execute(query) Observed behavior Query executed on August 14: historical step counts returned correctly Query executed on August 16: August 16 and August 15 returned correctly August 14 and earlier returned nil from sumQuantity() Query executed on August 18: historical step counts returned correctly again No query error was reported All step counts remained visible in the customer's Apple Health app Expected behavior The query should consistently return cumulative daily step counts when matching HealthKit samples exist and are visible in the Health app. Because this was reported through customer support, we do not currently know the exact iOS 27 beta build number. We are also unable to reproduce it consistently on our own test devices. Questions Is there a known intermittent issue with historical .stepCount queries on iOS 27 beta? Can HealthKit temporarily return incomplete statistics while data is being indexed, synchronized, or migrated? Is there a recommended way to detect that the returned statistics are temporarily incomplete? Should applications retry the query when older statistics unexpectedly return nil without an error? We have not received reports of this behavior from customers using iOS 26 or earlier. Thank you.
Replies
1
Boosts
0
Views
54
Activity
2d
iOS 27 Health permissions: a reckoning is coming
iOS 27 adds a second stage to HealthKit read authorization. After picking data types, the user chooses "Past 30 Days and Future Data" or "All Recorded Data and Future Data", with Allow disabled until one is selected. Every user of every health app now makes this call, in the first seconds of onboarding, with no real context about what the app needs. I don't think the scale of this has landed yet. A meaningful share of users will pick 30 days. multi-year health trends, month to month comparisons, all-time records: with 30 days these features don't get worse, they stop existing. And it breaks silently. The user sees empty charts and a app that doesn't do what the screenshots promised. They won't connect that to a sheet they tapped through on day one — they'll connect it to the app. That's the reckoning: a wave of one-star reviews and support mail for a decision the developer never saw and can't inspect. Because we can't inspect it .authorizationStatus(for:) deliberately hides read authorization and getRequestStatusForAuthorization only says whether prompting would show UI, so a 30-day grant and a genuinely new Apple Watch user look identical from the query layer. A callback when Health permissions change for a type — even without disclosing the new state — would go a long way here. And we can't route users to the fix. UIApplication.openSettingsURLString opens the app's own Settings page, which has no Health section. The real control sits at Settings › Privacy & Security › Health › — four levels deep, unreachable from any public API. My suggestion is a URL constant scoped to the calling app, the way openNotificationSettingsURLString (iOS 15.4+) and openDefaultApplicationsSettingsURLString (iOS 18.3+) already work. But that's just my idea; if there's a better mitigation, or something already planned, I'd like to hear it. Worth saying the privacy gain looks thin either way: the app keeps all future data indefinitely, so a 30-day grant becomes a full-history grant in thirty days for anyone who keeps the app. The window limits what's readable today, not what accumulates. iOS 27 release is approaching... I think this will cause problems 😞 Filed as FB24398048 and FB24398031
Replies
0
Boosts
0
Views
104
Activity
4d
Background Health Store Access for Lock Screen Widgets
It's fairly well know and stated that the Apple Health / HealthKit data store is unavailable when iPhone is locked. Since Lock Screen Widgets were introduced there's been a feature parity mismatch with Apple's own Fitness app which is able to display updating Activity Rings on the Lock Screen. Third party apps cannot do this and have to rely unlocking their device to then trigger an update. This means they often display stale and wrong Health data. With the release of iOS 18 beta, I see no changes to this... Is there anything I've missed? Currently for requesting the Timeline Updates on my Widget I have to just keep requesting updates as often as possible and hope that each time the iPhone might be unlocked.... This is inefficient and a waste of device resources. Even a Widget timeline reload API that let the developer say "Only call update if iPhone unlocked" would be useful.
Replies
4
Boosts
1
Views
1.8k
Activity
2w
Extended Runtime API - Health Monitoring
In the WWDC 2019 session "Extended Runtime for WatchOS apps" the video talks about an entitlement being required to use the HR sensor judiciously in the background. It provides a link to request the entitlement which no longer works: http://developer.apple.com/contect/request/health-monitoring The session video is also quite hard to find these days. Does anyone know why this is the case? Is the API and entitlement still available? Is there a supported way to run, even periodically, in the background on the Watch app (ignoring the background observer route which is known to be unreliable) and access existing HR sensor data
Replies
15
Boosts
1
Views
2.1k
Activity
2w
Beta testers wanted: Somataquest — personalized training and recovery insights
I’m looking for about 15 additional iPhone/iWatch users to test SomataQuest, an early-stage fitness app that uses Apple Health data to help users understand their recent training, recovery, and readiness for today’s activity. Learn more: https://www.nexuspointinnovations.com/somataquest TestFlight: https://testflight.apple.com/join/BjXUh9bj I’d especially appreciate testers trying the following: Connect Apple Health and complete the initial setup Check whether the readiness score and its explanation make sense Review whether the app represents your recent workouts and activity accurately Evaluate whether the suggested training intensity feels reasonable Report anything confusing, incorrect, slow, or broken The app currently works best for people who regularly record workouts, sleep, heart-rate, or activity data in Apple Health. Feedback can be submitted through TestFlight or posted in this thread. This is an early beta, so candid feedback—especially about what is unclear or not useful—is very welcome.
Replies
0
Boosts
0
Views
267
Activity
3w
Guideline 5.1.3(ii) — does encrypted, per-user private CloudKit storage count as "storing personal health information in iCloud"?
Guideline 5.1.3(ii) says apps "may not store personal health information in iCloud." Does this apply to any use of a private, per-user CloudKit database for health-related data, or is it specifically about unencrypted/shared storage, or data sourced from HealthKit? If a health app end-to-end encrypts sensitive fields so that even Apple's infrastructure can't read them, and the data never leaves the individual user's own iCloud account, does that change how 5.1.3(ii) applies — or is the guideline a blanket restriction regardless of encryption? Has anyone gotten reviewer feedback (approval or rejection) that clarifies how this is actually enforced in practice? Thanks in advance!
Replies
1
Boosts
0
Views
371
Activity
Jul ’26
HKStatisticsCollectionQueryDescriptor intermittently returns no data for certain date ranges on iOS 27
We are seeing inconsistent results from HKStatisticsCollectionQueryDescriptor on iOS 27. Using the same quantity type, statistics options, anchor date, interval components, and predicate configuration, some date ranges return the expected statistics, while other ranges unexpectedly return empty results or buckets with no quantity. The affected ranges do contain HealthKit samples: HKSampleQueryDescriptor finds samples in the same date range. HKStatisticsQueryDescriptor returns the expected value when run separately for an affected bucket. HKStatisticsCollectionQueryDescriptor returns no quantity for that same bucket. Slightly expanding or shifting the date range may cause the collection query to return data again. A simplified version of the query looks like this: let datePredicate = HKQuery.predicateForSamples( withStart: startDate, end: endDate, options: .strictStartDate ) let descriptor = HKStatisticsCollectionQueryDescriptor( predicate: .quantitySample( type: quantityType, predicate: datePredicate ), options: .cumulativeSum, anchorDate: anchorDate, intervalComponents: DateComponents(day: 1) ) let collection = try await descriptor.result(for: healthStore) collection.enumerateStatistics(from: startDate, to: endDate) { statistics, _ in let quantity = statistics.sumQuantity() print(statistics.startDate, quantity as Any) } Expected behavior Every interval containing matching samples should return the corresponding statistics, regardless of the overall requested date range. Actual behavior Some date ranges produce missing or empty buckets even though matching samples exist and an individual HKStatisticsQueryDescriptor can calculate the expected value. Changing only the date range can make the data appear or disappear. The samples are visible to the app in the affected range, so this does not appear to be explained solely by iOS 27’s Limited History authorization. This behavior was not observed with the same query flow on earlier iOS versions. Is this a known regression in HKStatisticsCollectionQueryDescriptor on iOS 27, or has the expected date-range or predicate behavior changed?
Replies
0
Boosts
0
Views
457
Activity
Jul ’26
HKWorkoutBuilder.finishWorkout intermittently returns nil workout and nil error while samples are successfully saved (iOS 26.4–27)
We're seeing an intermittent issue with HKWorkoutBuilder.finishWorkout() in our production app. Our workflow is: builder.beginCollection(withStart: start) { success, error in guard success else { return } let authorizedSamples = samples.filter { self.healthStore.authorizationStatus(for: $0.quantityType) == .sharingAuthorized } builder.add(authorizedSamples) { success, error in guard success else { return } builder.endCollection(withEnd: end) { success, error in guard success else { return } builder.finishWorkout { workout, error in print("workout = \(String(describing: workout))") print("error = \(String(describing: error))") } } } } The logs from affected users are: workout builder begin: result: true, error: nil authorized samples: - HKQuantityTypeIdentifierActiveEnergyBurned - HKQuantityTypeIdentifierDistanceWalkingRunning - HKQuantityTypeIdentifierStepCount workout builder add samples: result: true, error: nil workout builder end: result: true, error: nil workout builder finish: workout: nil, error: nil Result The quantity samples (active energy, distance, step count, etc.) are successfully written to Apple Health. However, no HKWorkout is created. Querying HealthKit immediately afterward also confirms that no HKWorkout exists for the corresponding time range. As a result: The workout does not appear in the Fitness app. It does not contribute to Activity Rings. The quantity samples are visible, but there is no associated workout. Environment We've received reports from multiple users on: iOS 26.4 iOS 26.5 iOS 26.6 iOS 27 beta The issue only affects a small percentage of users. The vast majority complete successfully using exactly the same code path. Things we've verified We've ruled out several common causes: The app is in the foreground (UIApplication.shared.applicationState == .active). The device is unlocked. All HealthKit write permissions have been granted. finishWorkout() is called immediately after endCollection() completes. The quantity samples are successfully saved. Querying HealthKit afterward confirms that the HKWorkout itself was never created. This appears to be different from the documented "device locked" behavior, since the device is unlocked and active when the issue occurs. We also found a related discussion: https://developer.apple.com/forums/thread/825838 In that thread, the issue seems to be related to a locked device. However, our issue also occurs while the device is unlocked and the app remains active. Has anyone experienced similar behavior? Have you found any workaround? Has Apple provided any update through Feedback Assistant or DTS? Has anyone successfully recovered from this state by retrying finishWorkout() or using another approach? We're happy to provide additional logs or a minimal reproducible example if that would be helpful.
Replies
0
Boosts
0
Views
444
Activity
Jul ’26
Apple Health not connecting Blood Pressure from OMRON App
iOS 27 beta 3 broke my Apple health and blood pressure monitor and according to omron app, everything is being sent to Apple health. All permissions given. But blood pressure will not transfer into health.
Replies
1
Boosts
0
Views
533
Activity
Jul ’26
Custom Exported Workout missing workoutPlan identifier / Metadata only on the very first app launch/install
Hello everyone, I am experiencing a strange issue regarding retrieving a custom tracking identifier (workoutPlan identifier) from a custom exported workout that has been imported via HealthKit. The Issue: First Fresh Install: When the app is installed for the first time and initialized, it fails to load/fetch the workout plan ID from the imported workout. Subsequent Launches / Re-installs: If I close and relaunch the app, the app successfully fetches the workout plan ID from HealthKit with absolutely no problems. Has anyone found a clean way to handle this without forcing a manual user refresh or an awkward delay/retry mechanism on the first launch? Any insight, workarounds, or best practices would be greatly appreciated! Environment: iOS 17+, Swift, HealthKit
Replies
3
Boosts
0
Views
552
Activity
Jul ’26
Custom Exported Workout missing workoutPlan identifier / Metadata only on the very first app launch/install
Hello everyone, I am experiencing a strange issue regarding retrieving a custom tracking identifier (workoutPlan identifier) from a custom exported workout that has been imported via HealthKit. The Issue: First Fresh Install: When the app is installed for the first time and initialized, it fails to load/fetch the workout plan ID from the imported workout. Subsequent Launches / Re-installs: If I close and relaunch the app, the app successfully fetches the workout plan ID from HealthKit with absolutely no problems. Has anyone found a clean way to handle this without forcing a manual user refresh or an awkward delay/retry mechanism on the first launch? Any insight, workarounds, or best practices would be greatly appreciated! Environment: iOS 17+, Swift, HealthKit
Replies
1
Boosts
0
Views
400
Activity
Jul ’26
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
586
Activity
Jul ’26
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
591
Activity
Jul ’26
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
549
Activity
Jun ’26
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
774
Activity
Jun ’26
Health permissions problem with watchOS 10.6.2
In the last few weeks 5 users have reported my workout watch app being unable to read health data despite the permissions being enabled in the iPhone Settings app. This has been a common complaint over the years and is usually fixed by disabling the permissions; rebooting both devices; and then enabling them again. This usually nudges iOS into sending the permissions to watchOS. However that procedure doesn't work for these users, all of whom are using watchOS 10.6.2. They are using various versions of iOS 18 or 26 so it seems to be a problem with that version of watchOS, which users are usually limited to because their hardware won't support anything more up to date. It seems that unpairing and re-pairing the watch can fix the problem but not always. I looked around and it seems that other apps are having the same problem: https://www.reddit.com/r/runna/comments/1rhhs2n/runna_wont_start_an_outdoor_run_on_apple_watch/ Does anyone know a way to fix this? My current advice is to repeatedly unpair / re-pair until it works, which isn't really practical! Thanks in advance.
Replies
3
Boosts
0
Views
983
Activity
Jun ’26
iOS and Apple touchscreen
would like to enable Apple touschscreens to measure a set of bio parameteres through NDR (negative differential resistance) at the finger tip, whereas the proprietary measurement therapeutically channels out current out of the finger
Replies
1
Boosts
0
Views
839
Activity
Jun ’26
Indoor workout location
In the Fitness app under iOS 26, each workout location is displayed on a small map. For workouts with routes, I can already successfully read out the route and thus also determine the starting point. So that works. For indoor workouts such as yoga or indoor rowing, the exact location is also displayed in the Fitness app. I would now also like to read out this location for these indoor workouts in my app. Does anyone know how to do this?
Replies
1
Boosts
0
Views
659
Activity
May ’26