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

Created

HKAnchoredObjectQuery ignores "no correlation" predicate in updateHandler
Hello, I'm seeing an inconsistency in how HKAnchoredObjectQuery applies predicates between its initial results handler and its update handler. Specifically, predicates that filter quantity samples by correlation membership - using either HKQuery.predicateForObjectsWithNoCorrelation() or NSPredicate(format: "%K == nil", HKPredicateKeyPathCorrelation) - are respected in the resultsHandler but silently ignored in the updateHandler. Setup I have three long-running HKAnchoredObjectQuery instances: One for HKCorrelationType(.bloodPressure) - no predicate One for HKQuantityType(.bloodPressureSystolic) - predicate: HKQuery.predicateForObjectsWithNoCorrelation() One for HKQuantityType(.bloodPressureDiastolic) - predicate: HKQuery.predicateForObjectsWithNoCorrelation() The intent of the predicate on the systolic/diastolic queries is to capture only standalone quantity samples written directly by third-party apps - not the constituent sub-samples of an HKCorrelation. The correlation query handles correlated samples. Expected behavior When a BloodPressure correlation is saved to the store, only the correlation query's updateHandler should fire, with 1 new sample. The systolic and diastolic updateHandlers should not fire, since those samples have correlation != nil which is excluded by the predicate. Actual behavior After saving one BloodPressure correlation, all three updateHandlers fire with 1 new object each. The systolic and diastolic update handlers receive the correlated sub-samples despite the predicateForObjectsWithNoCorrelation() predicate. The same predicate correctly filters those kinds of samples out of the initial resultsHandler. Additionally, the same predicate applied in a one-shot HKSampleQuery for the systolic or diastolic type correctly returns 0 results when only correlated readings exist. The problem is only experienced in updateHandler of a long-running HKAnchoredObjectQuery. Tested iOS versions iOS 26.3 iOS 18.7.6 Workaround When an HKAnchoredObjectQuery updateHandler fires with systolic or diastolic samples, I fire a one-shot HKSampleQuery with a compound predicate using the sample UUIDs and predicateForObjectsWithNoCorrelation. Any samples that are part of a correlation are not returned in the HKSampleQuery resultsHandler.
1
0
108
1w
Clarification on HealthKit Observer Delivery Frequency and BGTaskScheduler Behavior
Hi Team, We are implementing HealthKit data sync using HKObserverQuery along with enableBackgroundDelivery and BGTaskScheduler for fallback processing. However, we are observing inconsistent behavior and would like clarification on expected system behavior: For HKObserverQuery: When using enableBackgroundDelivery with frequency .immediate, we sometimes receive updates promptly, but other times we do not receive any trigger at all. Similarly, when using .hourly, our expectation was that updates would be delivered approximately once per hour, but in practice, triggers are delayed, batched, or skipped. For BGTaskScheduler: We are scheduling BGAppRefreshTask with earliestBeginDate set (e.g., 1 hour), but tasks are sometimes delayed by several hours or not triggered predictably. In some cases, tasks are not executed even after extended periods. We would like to understand: Are HKObserverQuery delivery frequencies (.immediate, .hourly, .daily) strictly best-effort hints rather than guaranteed intervals? Under what conditions can observer updates be skipped or significantly delayed? Is there any recommended approach to ensure more reliable periodic syncing of HealthKit data? For BGTaskScheduler, what factors most strongly influence scheduling delays or missed executions? Our goal is to design a reliable sync mechanism, but the lack of deterministic behavior is making it difficult to define expected system behavior. Any clarification or recommended best practices would be greatly appreciated. Thanks in advance!
1
0
99
1w
State of Mind and the free text: Can it be fetched?
Has anyone actually managed to read the free-text note/context from Apple Health State of Mind entries? I’m building an iOS app that reads HKStateOfMind data from HealthKit. I can get the expected stuff fine: valence labels associations But in the Health app, users can also add extra context text to a mood entry, like: Tasks, Weather - Great work-life balance From my app, I can read Tasks and Weather, but I can’t find the Great work-life balance part anywhere. I already checked: public HKStateOfMind properties metadata debug description / object description attachment-ish routes Nothing so far. So before I spend more time chasing this: is that text just not exposed to third-party apps? Or is there some weird HealthKit path I’m missing? If anyone has actually pulled this off, I’d love to know how.
0
0
77
1w
No Response for Family Controls Distribution Entitlement Request for 2 Weeks
Hello, I have submitted multiple requests for the Family Controls Distribution Entitlement through this form: https://developer.apple.com/contact/request/family-controls-distribution After submitting my requests, I waited for about 1 week but did not receive any response. Since I heard nothing, I contacted Apple Developer Support by email. After that, I finally received a response from an advisor asking for additional information, including my follow-up number. I replied with all the requested information immediately, but it has now been 5 more days and I still have not received any further response. In total, I have been waiting for about 2 weeks for this entitlement request. My app is a Screen Time control / digital wellbeing application that helps users reduce screen time through exercise-based challenges and healthy habits. My app uses the FamilyControls, ManagedSettings, and DeviceActivity frameworks and requires the Distribution Entitlement for App Store release. Here are my details: Case Number: 102866460896 Request Type: Family Controls Distribution Entitlement I understand the team may be busy, but I would appreciate any help checking the status of my request or escalating it if possible. Thank you very much.
1
0
31
5d
Clarification on HealthKit Background Access While Device Is Locked
Hello Apple Developer Support / Community, I would like clarification regarding HealthKit data access behavior when an iPhone is locked. We are building an app that uses: HKObserverQuery enableBackgroundDelivery HKAnchoredObjectQuery Background execution to sync HealthKit data to our server Our specific question is: When the device is locked with passcode/Face ID protection enabled, can an app launched in the background through HKObserverQuery or other background mechanisms reliably access and read HealthKit data? We would like to understand the expected Apple-supported behavior for the following scenarios: If new HealthKit samples are written while the phone is locked, will HKObserverQuery still trigger immediately? If the observer callback is invoked while locked, can HKAnchoredObjectQuery successfully read the new samples? Is HealthKit data inaccessible while locked due to Data Protection / encrypted store behavior? Should developers expect delivery or data reads to be deferred until the user unlocks the device? We are trying to set correct expectations for background syncing and would appreciate official clarification on whether near real-time HealthKit sync is possible while the device remains locked. Relevant documentation mentions HealthKit store encryption, but we would appreciate direct confirmation for production behavior. Thank you.
0
0
45
4d
Clarification on HealthKit Observer Behavior in Flutter App vs Native iOS App
Hello Apple Developer Support / Community, I would like clarification regarding HealthKit observer behavior when comparing a Flutter-based iOS app with a fully native iOS app. We are using HealthKit background delivery with: HKObserverQuery enableBackgroundDelivery HKAnchoredObjectQuery We have observed that in a Flutter-based app, HKObserverQuery callbacks appear to execute multiple times or more frequently than expected for a single data update. In comparison, a native iOS implementation using similar HealthKit logic appears more stable and predictable. We would like to understand the expected platform behavior and whether there are any known considerations from Apple’s perspective. Specific questions: Does iOS treat HealthKit observer delivery differently for apps built with Flutter versus fully native UIKit / Swift apps? Are there known issues where app lifecycle handling, Flutter engine initialization, method channels, isolates, or plugin architecture could cause repeated observer callbacks? Can repeated HKObserverQuery executions occur if queries are registered multiple times during app launches or engine restarts? Does Apple recommend any specific observer management pattern for cross-platform frameworks such as Flutter? From the HealthKit system side, should observer callback frequency be identical regardless of whether the app is Flutter or native, assuming the same iOS code is used? We are trying to determine whether this behavior is due to HealthKit delivery semantics, duplicate observer registration, Flutter lifecycle integration, or framework-related limitations. Any guidance from Apple or developers who have implemented HealthKit successfully in Flutter would be appreciated. Thank you.
1
0
103
4d
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.
0
0
38
2d
HKAnchoredObjectQuery ignores "no correlation" predicate in updateHandler
Hello, I'm seeing an inconsistency in how HKAnchoredObjectQuery applies predicates between its initial results handler and its update handler. Specifically, predicates that filter quantity samples by correlation membership - using either HKQuery.predicateForObjectsWithNoCorrelation() or NSPredicate(format: "%K == nil", HKPredicateKeyPathCorrelation) - are respected in the resultsHandler but silently ignored in the updateHandler. Setup I have three long-running HKAnchoredObjectQuery instances: One for HKCorrelationType(.bloodPressure) - no predicate One for HKQuantityType(.bloodPressureSystolic) - predicate: HKQuery.predicateForObjectsWithNoCorrelation() One for HKQuantityType(.bloodPressureDiastolic) - predicate: HKQuery.predicateForObjectsWithNoCorrelation() The intent of the predicate on the systolic/diastolic queries is to capture only standalone quantity samples written directly by third-party apps - not the constituent sub-samples of an HKCorrelation. The correlation query handles correlated samples. Expected behavior When a BloodPressure correlation is saved to the store, only the correlation query's updateHandler should fire, with 1 new sample. The systolic and diastolic updateHandlers should not fire, since those samples have correlation != nil which is excluded by the predicate. Actual behavior After saving one BloodPressure correlation, all three updateHandlers fire with 1 new object each. The systolic and diastolic update handlers receive the correlated sub-samples despite the predicateForObjectsWithNoCorrelation() predicate. The same predicate correctly filters those kinds of samples out of the initial resultsHandler. Additionally, the same predicate applied in a one-shot HKSampleQuery for the systolic or diastolic type correctly returns 0 results when only correlated readings exist. The problem is only experienced in updateHandler of a long-running HKAnchoredObjectQuery. Tested iOS versions iOS 26.3 iOS 18.7.6 Workaround When an HKAnchoredObjectQuery updateHandler fires with systolic or diastolic samples, I fire a one-shot HKSampleQuery with a compound predicate using the sample UUIDs and predicateForObjectsWithNoCorrelation. Any samples that are part of a correlation are not returned in the HKSampleQuery resultsHandler.
Replies
1
Boosts
0
Views
108
Activity
1w
Clarification on HealthKit Observer Delivery Frequency and BGTaskScheduler Behavior
Hi Team, We are implementing HealthKit data sync using HKObserverQuery along with enableBackgroundDelivery and BGTaskScheduler for fallback processing. However, we are observing inconsistent behavior and would like clarification on expected system behavior: For HKObserverQuery: When using enableBackgroundDelivery with frequency .immediate, we sometimes receive updates promptly, but other times we do not receive any trigger at all. Similarly, when using .hourly, our expectation was that updates would be delivered approximately once per hour, but in practice, triggers are delayed, batched, or skipped. For BGTaskScheduler: We are scheduling BGAppRefreshTask with earliestBeginDate set (e.g., 1 hour), but tasks are sometimes delayed by several hours or not triggered predictably. In some cases, tasks are not executed even after extended periods. We would like to understand: Are HKObserverQuery delivery frequencies (.immediate, .hourly, .daily) strictly best-effort hints rather than guaranteed intervals? Under what conditions can observer updates be skipped or significantly delayed? Is there any recommended approach to ensure more reliable periodic syncing of HealthKit data? For BGTaskScheduler, what factors most strongly influence scheduling delays or missed executions? Our goal is to design a reliable sync mechanism, but the lack of deterministic behavior is making it difficult to define expected system behavior. Any clarification or recommended best practices would be greatly appreciated. Thanks in advance!
Replies
1
Boosts
0
Views
99
Activity
1w
State of Mind and the free text: Can it be fetched?
Has anyone actually managed to read the free-text note/context from Apple Health State of Mind entries? I’m building an iOS app that reads HKStateOfMind data from HealthKit. I can get the expected stuff fine: valence labels associations But in the Health app, users can also add extra context text to a mood entry, like: Tasks, Weather - Great work-life balance From my app, I can read Tasks and Weather, but I can’t find the Great work-life balance part anywhere. I already checked: public HKStateOfMind properties metadata debug description / object description attachment-ish routes Nothing so far. So before I spend more time chasing this: is that text just not exposed to third-party apps? Or is there some weird HealthKit path I’m missing? If anyone has actually pulled this off, I’d love to know how.
Replies
0
Boosts
0
Views
77
Activity
1w
No Response for Family Controls Distribution Entitlement Request for 2 Weeks
Hello, I have submitted multiple requests for the Family Controls Distribution Entitlement through this form: https://developer.apple.com/contact/request/family-controls-distribution After submitting my requests, I waited for about 1 week but did not receive any response. Since I heard nothing, I contacted Apple Developer Support by email. After that, I finally received a response from an advisor asking for additional information, including my follow-up number. I replied with all the requested information immediately, but it has now been 5 more days and I still have not received any further response. In total, I have been waiting for about 2 weeks for this entitlement request. My app is a Screen Time control / digital wellbeing application that helps users reduce screen time through exercise-based challenges and healthy habits. My app uses the FamilyControls, ManagedSettings, and DeviceActivity frameworks and requires the Distribution Entitlement for App Store release. Here are my details: Case Number: 102866460896 Request Type: Family Controls Distribution Entitlement I understand the team may be busy, but I would appreciate any help checking the status of my request or escalating it if possible. Thank you very much.
Replies
1
Boosts
0
Views
31
Activity
5d
Clarification on HealthKit Background Access While Device Is Locked
Hello Apple Developer Support / Community, I would like clarification regarding HealthKit data access behavior when an iPhone is locked. We are building an app that uses: HKObserverQuery enableBackgroundDelivery HKAnchoredObjectQuery Background execution to sync HealthKit data to our server Our specific question is: When the device is locked with passcode/Face ID protection enabled, can an app launched in the background through HKObserverQuery or other background mechanisms reliably access and read HealthKit data? We would like to understand the expected Apple-supported behavior for the following scenarios: If new HealthKit samples are written while the phone is locked, will HKObserverQuery still trigger immediately? If the observer callback is invoked while locked, can HKAnchoredObjectQuery successfully read the new samples? Is HealthKit data inaccessible while locked due to Data Protection / encrypted store behavior? Should developers expect delivery or data reads to be deferred until the user unlocks the device? We are trying to set correct expectations for background syncing and would appreciate official clarification on whether near real-time HealthKit sync is possible while the device remains locked. Relevant documentation mentions HealthKit store encryption, but we would appreciate direct confirmation for production behavior. Thank you.
Replies
0
Boosts
0
Views
45
Activity
4d
Clarification on HealthKit Observer Behavior in Flutter App vs Native iOS App
Hello Apple Developer Support / Community, I would like clarification regarding HealthKit observer behavior when comparing a Flutter-based iOS app with a fully native iOS app. We are using HealthKit background delivery with: HKObserverQuery enableBackgroundDelivery HKAnchoredObjectQuery We have observed that in a Flutter-based app, HKObserverQuery callbacks appear to execute multiple times or more frequently than expected for a single data update. In comparison, a native iOS implementation using similar HealthKit logic appears more stable and predictable. We would like to understand the expected platform behavior and whether there are any known considerations from Apple’s perspective. Specific questions: Does iOS treat HealthKit observer delivery differently for apps built with Flutter versus fully native UIKit / Swift apps? Are there known issues where app lifecycle handling, Flutter engine initialization, method channels, isolates, or plugin architecture could cause repeated observer callbacks? Can repeated HKObserverQuery executions occur if queries are registered multiple times during app launches or engine restarts? Does Apple recommend any specific observer management pattern for cross-platform frameworks such as Flutter? From the HealthKit system side, should observer callback frequency be identical regardless of whether the app is Flutter or native, assuming the same iOS code is used? We are trying to determine whether this behavior is due to HealthKit delivery semantics, duplicate observer registration, Flutter lifecycle integration, or framework-related limitations. Any guidance from Apple or developers who have implemented HealthKit successfully in Flutter would be appreciated. Thank you.
Replies
1
Boosts
0
Views
103
Activity
4d
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
0
Boosts
0
Views
38
Activity
2d