Is there way to read the Apple Heart rate zones from HealthKit? I want to read the min/max bpm for each of the 1-5 zones.
I went through the Apple HealthKit developer documentation but couldn't find it https://developer.apple.com/documentation/healthkit
Health & Fitness
RSS for tagExplore the technical aspects of health and fitness features, including sensor data acquisition, health data processing, and integration with the HealthKit framework.
Post
Replies
Boosts
Views
Activity
we are seeing what appears to be an internal healthkit error appearing in our app. not sure if it's connected, but we've mostly seen it reported on devices running ios 16. even though our app's primary language is japanese, and in all reported occurrences the app was running in japanese, the error message itself appears in english. searching the error string on the web yields surprisingly few results (including only two mentions on this forum that i could find, neither of which seemed relevant). this would seem to suggest that it's coming from something deep inside healthkit, since the error message is not localized.
in all reported cases, the user had recently upgraded to a new iphone. in most cases, the problem only occurs on the new device even though everything had been working correctly prior to the upgrade. the error occurs when the app is unable to read step count data from healthkit.
we have confirmed that the app has been granted access permissions to all health data via os settings. we've also tried having the user toggling those settings off, then back on, rebooting the device, deleting and reinstalling the app, etc., to no avail.
the error message is "Unable to invalidate interval: no data source avallable."
we'd appreciate it if anyone can shed more light on this issue.
thanks!
Hello,
The new mental health features in iOS 17 allow users to log their momentary emotions and daily moods, see valuable insights, and easily access assessments and resources. Does anyone know if HealthKit in iOS 17 provides an API for accessing these records? Thanks :)
Hi,
Our app has an HKObserverQuery and calls enableBackgroundDelivery(...)
While running on an iPhone the background wakeup happens. While running on an iPad, it doesn't. The app can successfully query for data while in the foreground on an iPad.
Is background delivery expected to work on iPad?
After some years our app has been writing some data to HealthKit we decided to remove this functionality from the app. Permissions were removed from requestAuthorization(toShare:read:completion:) method. For new users everything works fine, but for users who were already asked for writing permission in Settings toggles for permissions are still on. Is it any way to update toggles list in Settings for actual state of permissions? Thanks in advance.
I have created a new project and I have added HomeKit capability but the two control box for Clinical Health Records
and Background Delivery can not be switched on.
are there any suggestion?
thanks a lot
valerio
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)
Hello, it is discussed here https://developer.apple.com/videos/play/wwdc2023/10016/ (12:16) regarding WorkoutComposition, but unfortunately, I cannot find this class or structure in the documentation. Has this concept been removed?
Hi.
is it possible to create a Custom Workout with different activity types.
I want a Custom Workout where the user first has to run and after do skiing.
Its like a little bit like SwimBikeRun but with running and Skiing.
How can i do this?
Thank you
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
Hi,
The fitness features such as distance moved, steps, calories burned is it in HealthKit or in a different kit ? couldn't find any API in HealthKit ?
Also for example how can Apple Watch distinguish that this amount of steps was walked and not moved by a slow car or a scoter for example ?
Kindest Regards
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.
Can you track steps on ipad 9th gen?
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.
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])
}
}
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)
}
When obtaining the running data of the Apple Watch in the health App, the segmented average heart rate obtained is inconsistent with the data displayed in the health App. Have you encountered it?
I am reading sleep data from AppleHealthKit API that have wearables connected.
Is it possible to retrieve:
If data came from wearable (e.g.--> True/False)
Wearable brand / Model (e.g. apple or Applewatch2)
Software Version (e.g. 1.3.4)
Are there specific permissions that need to be asked to retrieve source data?
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.
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