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

Post

Replies

Boosts

Views

Activity

HealthKit Blood Pressure Data Toggle Issue in React Native App
Hello, We are currently developing a healthcare app using React Native and have successfully implemented the feature to fetch data such as step count, weight, blood pressure, and heart rate from HealthKit. While we have no issues with the data retrieval itself, we have encountered a problem regarding the blood pressure data. In HealthKit's Heart → Blood Pressure → Data Sources & Access section, the "APPS AND SERVICES ALLOWED TO READ DATA" shows as "NONE," and there's no option within HealthKit to toggle the connection ON or OFF. Instead, the control for ON/OFF is available in the iPhone's SETTINGS → Health → Data Sources & Access, specifically for "Diastolic Blood Pressure" and "Systolic Blood Pressure". Please note that the ability to toggle ON/OFF within HealthKit is available for step count, weight, and heart rate. Could this issue with blood pressure data be due to the requirement of two permissions (for diastolic and systolic readings), and that's why it's not displayed correctly in HealthKit? What are the possible solutions for controlling the blood pressure data ON/OFF toggle within HealthKit?
0
0
432
Apr ’24
How can I access the HKMetadataKeySwimmingStrokeStyle enum?
I'm looking at a swimming workout sample and in the metadata I see: Optional(["HKIndoorWorkout": 0, "HKSwimmingLocationType": 2, "HKAverageMETs": 10.7366 kcal/hr·kg, "HKTimeZone": America/New_York]) There is no mention of the HKMetadataKeySwimmingStrokeStyle yet when I look at the workout in the Apple Fitness app, there is stroke style data. How can I access the stroke enum?
0
0
435
Feb ’24
HealthKit permission sheet appears every time for some users - bug?
The HealthKit permission sheet is showing up every time the app opens for a few users of my app. It doesn't matter what action they take in the sheet. I have had them try toggling the permissions from the HealthKit system settings but that did not happen to fix the problem. Has anyone experienced this problem or know a fix? Its affecting a few users of my app. I haven't been able to find what in my code could be doing this, I suspect its a bug on HealthKit's side for specific users. I can't find anyone reporting this problem elsewhere so I have to assume its my fault, but the docs clearly state that the permission sheet will only be presented once.
2
2
518
Feb ’24
Inquiry Regarding Documentation Requirements for Research-Based Healthcare Applications
Dear Apple App Store Team, I am reaching out to seek clarity and guidance specifically regarding the documentation requirements for submitting a research-based healthcare application on the App Store. Our development team is committed to ensuring compliance with all relevant guidelines, and we would appreciate your assistance in understanding the specific documentation needed for these applications. As our application involves collecting data from patients for research purposes, we want to ensure that we provide the necessary documentation to support our submission. Here are the key areas for which we are seeking clarification: Consent Documentation: Any specific forms or templates required to demonstrate the obtaining of informed consent, especially for minors where parental consent is involved. Research Nature, Purpose, and Duration: Guidance on documenting and communicating the nature, purpose, and expected duration of the research to the participants. Procedures, Risks, and Benefits: Clarity on the documentation needed to communicate the research procedures, potential risks, and expected benefits to the participants or users. Confidentiality and Data Handling: Any specific documentation or information required demonstrating how confidentiality will be maintained and how data collected during the research will be handled, including any sharing with third parties. Participant Contact Information: Guidance on providing a point of contact for participant questions and inquiries. Withdrawal Process Information: Documentation needed to explain the withdrawal process for participants who choose to discontinue their involvement in the research. Ethics Review Board Approval: Specific requirements for providing proof of approval from an independent ethics review board, including any templates or forms that may be necessary. Understanding these specific requirements will enable us to compile a comprehensive submission package tailored to the expectations of the App Store review process for research-based applications. We appreciate your attention to this matter and look forward to your guidance. If there are any specific forms or templates that should accompany our submission, kindly let us know. Thank you for your time and assistance. Best regards, Youcef Barkat
0
0
391
Feb ’24
Can we capture beat to beat intervals in a workout app?
Hi, I can find no way of getting HKSeriesType.heartbeat() data from the health store using my own workout app. The values captured seem to be from the irregular HRV measurements done by Apple. There is a video showing HKHeartbeatSeriesSamples being consumed in an app but not how to capture them from the optical sensor. The WWDC video on this https://stackoverflow.com/questions/77950041/getting-heartbeatseriessamples-in-ios-swift-healthkit-hkanchoredobjectquery at around 28 mins assumes you have written the beats from an external device - not from the optical sensor. I have set typesToRead to be: // Beat addition HKSeriesType.heartbeat(), HKQuantityType.quantityType(forIdentifier: .heartRateVariabilitySDNN)!, // end beat addition Why is the watch app not saving beat to beat interval series to the health store?? Failing that how can the watch app access the data itself so that it can then forward to the companion iPhone app? Help much appreciated.
0
0
441
Feb ’24
HKCategoryValueSleepAnalysis Sending incorrect sleep data.
The edited code still has the problem of not lining up with the health app private func fetchSleepData(for date: Date) { let sleepType = HKObjectType.categoryType(forIdentifier: .sleepAnalysis)! let endOfPeriod = date let startOfPeriod = Calendar.current.date(byAdding: .day, value: -1, to: endOfPeriod)! let predicate = HKQuery.predicateForSamples(withStart: startOfPeriod, end: endOfPeriod, options: [.strictStartDate, .strictEndDate]) let query = HKSampleQuery(sampleType: sleepType, predicate: predicate, limit: HKObjectQueryNoLimit, sortDescriptors: nil) { query, samples, error in guard let samples = samples as? [HKCategorySample], !samples.isEmpty else { DispatchQueue.main.async { self.inBedTime = 0 self.coreTime = 0 self.deepTime = 0 self.remTime = 0 self.isSleepDataAvailable = false } print("No sleep data available for date: \(date)") return } print("Fetched \(samples.count) sleep samples for date: \(date)") var inBedTime = 0.0 var asleepTime = 0.0 var deepTime = 0.0 var remTime = 0.0 for sample in samples { print("Sample value: \(sample.value)") let duration = sample.endDate.timeIntervalSince(sample.startDate) / 60 // convert to minutes switch sample.value { case HKCategoryValueSleepAnalysis.inBed.rawValue: inBedTime += duration case HKCategoryValueSleepAnalysis.asleepCore.rawValue: coreTime += duration case HKCategoryValueSleepAnalysis.asleepDeep.rawValue: deepTime += duration case HKCategoryValueSleepAnalysis.asleepREM.rawValue: remTime += duration default: break } } DispatchQueue.main.async { self.inBedTime = inBedTime self.coreTime = coreTime self.deepTime = deepTime self.remTime = remTime self.isSleepDataAvailable = true } } healthStore?.execute(query) }
1
0
508
Jan ’24
Need help with Customizing workouts with WorkoutKit
Please reference the Sample Planner app which can be found at the below link. https://developer.apple.com/documentation/WorkoutKit/customizing-workouts-with-workoutkit. In WorkoutStore.swift, all of the values are hard coded. I would like to turn them into variables stored in @EnvironmentObject (WorkoutStoreValue). With the below code, using "singleRunStartDelay" as a trial, I can get that variable passed to the WorkStore struct only when the app is first opened, however, I have not been able to get it changed in realtime. I need help with changing the WorkoutStore struct to have the values updated in realtime. I have tried changing the func from static but that gives an error (Instance member 'createSingleRunWorkout' cannot be used on type 'WorkoutStore'; did you mean to use a value of this type instead?) I'm now learning Xcode/SwiftUI. I have been stuck for about four day trying many different ideas. Thanks // Copyright © 2024 Apple. All rights reserved. /* The structure that returns running workout compositions. */ import HealthKit import WorkoutKit import SwiftUI import Foundation struct WorkoutStore{ @EnvironmentObject var workoutStoreValue: WorkoutStoreValue static func createSingleRunWorkout() -> CustomWorkout { let getReadyStep = WorkoutStep(goal: .open) //fixed to .open let singleRunDelay = WorkoutStoreValue.shared.singleRunStartDelay var onYourMarkStep = IntervalStep(.work) onYourMarkStep.step.goal = .time(Double(singleRunDelay), .seconds) //you have this much time to start var runStep = IntervalStep(.work) runStep.step.goal = .distance(100, .meters) //hard coded for now. Need to insert distance variable here runStep.step.alert = .speed(3...4, unit: .metersPerSecond, metric: .current) // Would like to insert alert variables here var block = IntervalBlock() block.steps = [ onYourMarkStep, runStep ] block.iterations = 1 //fixed at 1. Would like to insert as a variable return CustomWorkout(activity: .running, location: .outdoor, displayName: "Single run mode", warmup: getReadyStep, blocks: [block]) } }
2
0
435
Jan ’24
Can HKWorkout be made Codable?
I'm thinking about developing a workout tracking app. To avoid the issue of having to repeatedly download workouts, I want to persist some app model data like Apple does with their Fitness App. At a minimum, the HKWorkout class. Has anyone seen this done before? I'd hate to have reinvent the wheel. HKWorkout: HKSample: HKObject: NSObject.
0
0
427
Jan ’24
Inaccurate query results of HKStatisticsCollectionQuery
I have the same issues, when i use HKStatisticsCollectionQuery query user step count, there's a big difference in the number of steps I'm query before and after a minute's interval. 2023-12-17 15:45:41 steps=529 2023-12-17 15:46:52 steps=5817 2023-12-19 19:43:59 steps=2680 2023-12-19 19:44:31 steps=5554 What is causing this issue? I would like some assistance, please.
0
0
433
Dec ’23
First step in WorkoutKit
Hi there, I'm new here, looking for a step-by-step tutorial that will help me to achieve my first step. https://developer.apple.com/documentation/workoutkit/customizing-workouts-with-workoutkit downloaded the WorkoutKit sample file. try to run, and connect to my account and team but get an error to connect a device. Your team has no devices from which to generate a provisioning profile. Connect a device to use or manually add device IDs in Certificates, Identifiers & Profiles. https://developer.apple.com/account/ " I logged in to my web account but didn't find any device IDs in Certificates, Identifiers & Profiles section
0
0
459
Dec ’23
Workouts created with SingleGoalWorkout do not have a display name, as opposed to workouts created with CustomWorkout. Why is that?
With CustomWorkout, I can assign a name (displayName) to workouts, which also appears in the Workout app. Unfortunately, this parameter is missing for common workouts such as SingleGoalWorkout. Is there a reason for this? I find it inconvenient when the name is missing CustomWorkout init(activity: HKWorkoutActivityType, location: HKWorkoutSessionLocationType, displayName: String?, warmup: WorkoutStep?, blocks: [IntervalBlock], cooldown: WorkoutStep?) SingleGoalWorkout init(activity: HKWorkoutActivityType, location: HKWorkoutSessionLocationType, swimmingLocation: HKWorkoutSwimmingLocationType, goal: WorkoutGoal)
0
0
408
Dec ’23