Dear Apple Team,
QSFA app belongs to the Ministry of Sports and Youth in Qatar and there's a feature which will get the step count from the Apple health kit.
Our issue that while the app is closed or on the background, we are not getting the steps count for the users and we need the steps data to keep sending notifications based on the steps as motivations to the users to keep walking and do sport.
Please give us a suggestion or solution on how we can retrieve the steps data as we have limitations on this.
Use HealthKit to enable your iOS and watchOS apps to work with the Apple Health app.
Post
Replies
Boosts
Views
Activity
Hello,
I am writing workout data into HealthKit using the HKWorkoutBuilder API for specific types of workouts (e.g. Cycling) in particular various time series data for power, speed, etc.. but I am unable to see the average values for these quantities on the workout summary page in the Apple Fitness app ? (I am only able to see the graph data in the show more / workout details) anything specific to be done in order to have the data shown in the main summary ?
As the HealthKit is available for VisionOS, but there is no Health app. When will the Health app be available in VisionOS?
This has long been a frustration of mine on Apple Watch, and I've brought it up at WWDC labs every year to no avail but while the limitation on the Apple Watch to only be able to query 7 days of HealthKit data may have made sense early in the AW's lifetime for battery preservation etc., it really no longer makes sense in modern AW development.
Especially not with stand alone watch apps, as a developer I am prohibited from building the same experience on the Apple Watch that I can in an iPhone app. For example, my app looks at your current health metrics and compares them to your 60 day baseline to identify any deviations from your normal ranges. I cannot create the same experience on the watch using purely HealthKit queries, and am limited to using either iCloud or Watch Connectivity which have their own drawbacks and are not an option for a stand alone watch app.
Can we finally expand the length of HealthKit queries the AW can make so that we can build the same powerful experience on the watch that we can on iPhone?
Thank you!
Gary
See also Feedback FB7649612 (from April 2020).
Are there any changes in the frequency of HRV samples the Apple Watch takes in watchOS 11? Currently sample rates are very low except for users who have Afib History turned on. There should be some other way for users to get the benefit of more HRV sampling per day without needing to turn Afib History on if they haven't been diagnosed with Afib.
Also is it possible for a 3rd party app to trigger an HRV sample?
Thanks!
Gary
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.
Hi everyone,
With iOS 18 and watchOS 11 it is possible to pause your activity rings so that a streak is not broken when you are ill or something like that.
When we request data from the HealthStore, is there a way to know that a user has set this option for a particular date or period?
Or will the data for that date just return nil for all 3 ring values or even skip the day in the dataset?
I have an app in which I also keep track of people's streaks, so it would really useful to know if the activity rings are paused.
Thanks in advance!
The session Build custom swimming workouts with WorkoutKit mentions Outdoor activities supporting distance goals and lists:
Cycling
Running
Hiking
Walking
Swimming
Wheelchair walk + run
And new:
Golf
Rowing
Downhill skiing
Snowboarding
Lacrosse
Hockey
Disc Sports
Skating
Paddle sports
Soccer
American football
Australian football
Rugby
Cross country skiing
I know the previous 6 have GPS tracks saved with the workout in Health.
Do all of the other ones now also save the GPS track to Health?
If not all of them, which do?
I have noticed that my Apple Watch app seems to randomly quit from time to time. It's not crashing and I have not been able to reproduce it in a controlled setting, but have noticed that it seems to only happen when I'm in very high or low temperatures. For instance, I was skiing recently and my app was supposed to stay running the whole time, but often when I would raise my wrist it would be back on the home screen and my app wasn't running. This also happened when I was on the beach on a very hot day. But when I'm testing it at home I can keep it running for hours and it never crashes, which leads me to believe it may have to do with the temperature. Does the OS kill apps when it's running in very high or low temperatures? If so, is there anything I can do to prevent this from occurring?
Would doing less things in my app possibly prevent this? For instance, I have a timer, and use a bunch of sensors, would turning those off at times and using less of the display make a difference or does the OS not care what the apps are actually doing? If not, any other ideas?
Thanks
Hello,
I am developing an Apple Watch app in Swift and SwiftUI that needs to receive real-time heartbeat data to visualize the time intervals between heartbeats. The app draws circles on the screen where the size and position of each circle are based on the time interval between consecutive heartbeats.
I am currently using the HKQuantityType for .heartRate from HealthKit to get heart rate data and calculate the intervals. However, I am wondering if this is the best approach for my requirement. I came across the HKElectrocardiogram class, and I am not sure if it would be a better fit for obtaining real-time heartbeat intervals.
My questions are:
Real-Time Heartbeats:
Is HKQuantityType for .heartRate the most appropriate way to get real-time heartbeat data for calculating intervals between beats?
Can HKElectrocardiogram provide real-time heartbeat intervals, or is it more suited for detailed ECG recordings rather than instantaneous heartbeats?
Accuracy and Performance:
Which method provides the most accurate and real-time data for heartbeat intervals?
Are there any other APIs or services in the Apple Watch ecosystem that I should consider for this purpose?
Best Practices:
What are the best practices for implementing real-time heartbeat monitoring in an Apple Watch app?
Are there any sample projects or documentation that could help me understand the optimal way to achieve this?
Here is a brief overview of my current implementation using HKQuantityType for .heartRate:
import Foundation
import HealthKit
class HeartRateMonitor: NSObject, ObservableObject {
@Published var heartRate: Double = 0.0
@Published var intervals: [TimeInterval] = []
private var lastHeartRateTimestamp: Date?
private var healthStore: HKHealthStore?
private let heartRateQuantityType = HKObjectType.quantityType(forIdentifier: .heartRate)
private let appStartTime: Date
override init() {
self.appStartTime = Date()
super.init()
if HKHealthStore.isHealthDataAvailable() {
self.healthStore = HKHealthStore()
self.requestAuthorization()
}
}
private func requestAuthorization() {
guard let heartRateQuantityType = self.heartRateQuantityType else { return }
healthStore?.requestAuthorization(toShare: nil, read: [heartRateQuantityType]) { success, error in
if success {
self.startMonitoring()
}
}
}
func startMonitoring() {
guard let heartRateQuantityType = self.heartRateQuantityType else { return }
let query = HKAnchoredObjectQuery(
type: heartRateQuantityType,
predicate: nil,
anchor: nil,
limit: HKObjectQueryNoLimit) { (query, samples, deletedObjects, newAnchor, error) in
guard let samples = samples as? [HKQuantitySample] else { return }
self.process(samples: samples)
}
query.updateHandler = { (query, samples, deletedObjects, newAnchor, error) in
guard let samples = samples as? [HKQuantitySample] else { return }
self.process(samples: samples)
}
healthStore?.execute(query)
}
private func process(samples: [HKQuantitySample]) {
for sample in samples {
if sample.endDate > appStartTime {
let heartRateUnit = HKUnit.count().unitDivided(by: HKUnit.minute())
let heartRate = sample.quantity.doubleValue(for: heartRateUnit)
DispatchQueue.main.async {
self.heartRate = heartRate
if let lastTimestamp = self.lastHeartRateTimestamp {
let interval = sample.endDate.timeIntervalSince(lastTimestamp)
self.intervals.append(interval)
}
self.lastHeartRateTimestamp = sample.endDate
}
}
}
}
}
Thank you for your guidance and suggestions!
Our watchOS app uses CMFallDetectionManager (with the proper entitlement) to help alert our users and their caregivers when a fall occurs. We have had a simple implementation in our app for a couple of years now and it seems to work fine.
Recently, we received a report of delayed fall alerts and have traced back the root cause to a failure from the system to call func fallDetectionManager(_ fallDetectionManager: CMFallDetectionManager, didDetect event: CMFallDetectionEvent, completionHandler handler: @escaping () -> Void) promptly when a fall occurs.
Our implementation of this method begins with the following logging statement: "Fall detected at \(event.date) with status \(event.resolution.rawValue) at \(Date())"
When we check our logs, we see a number of events that occur as expected, for example: Fall detected at DATE_AND_HOURS:42:09 +0000 with status 1 at DATE_AND_HOURS:42:51 +0000
However, many events show a period of several minutes from fall detection to a report: Fall detected at DATE_AND_HOURS:28:09 +0000 with status 0 at DATE_AND_HOURS:32:42 +0000 or Fall detected at DATE_AND_HOURS:44:26 +0000 with status 1 at DATE_AND_HOURS:48:14 +0000
And in the instance from our customer, we had a fall detected that evidently wasn't reported for 5 hours and 4 minutes (I'm not sharing exact timestamps publicly to maintain user privacy).
We are aware of the documentation regarding the delegate and have programmed it appropriately not to receive duplicate events:
Additionally, each time the user launches your app, the system checks to see if a fall event has occurred during the recent past. If one has occurred, it calls this method.
Note that your app may receive the same event multiple times, for example, if the app crashes and relaunches. Always check the event’s date property to determine whether your app has already received the event. The system guarantees that different fall events have different date values.
Moreover, our logger persists logs when there is no network access, and the delegate callback also requests a network post to our servers that, again, is preserved in a background queue until connectivity is restored if it's not available. Our app's other updates (watchOS complication, etc.) from this user's Watch also show that our app was running in the background and communicating with our servers during that time. We have very high confidence that the watch and our app did not miss any more timely calls to that delegate method.
While this one five-hour delay was an exceptionally bad occurrence, we also find the other delays of several minutes to be concerning, considering the time-sensitive nature of falls. Does Apple or do any developers have any insights about what's going on and what expectations we should be setting for our users?
I am running two different background modes(not at the same time), 1 with a workout and 1 with a location. I noticed that the app logo appears above the watch face for both background modes but does not show up consistently. I wonder what the significance of the logo showing up above watch face is? Additionally why does it show up sometimes but not others?
Thanks
I'm using the new watchOS 9 HKWorkoutActivity in my interval training app (Intervals Pro) for each interval. It's a great addition since all the intervals now show in the Apple Fitness app, however, if the workout has lots of activities then saving the workout is painfully slow. For example, on my Apple Watch Ultra I saved a workout with 63 activities and it took more than 1 minute. Here's a code snippet:
try await builder.endCollection(at: workoutEndDate)
try await builder.addMetadata(metadata)
try await builder.finishWorkout() // This is SLOW
Is anyone else having the same issue?
To demonstrate the issue you can look at a Test Flight build of Intervals Pro:
https://testflight.apple.com/join/Nn7iSOzY
Tap on the More tab in the iPhone app and then the Apple Watch Settings. On that screen you'll see a switch to either enable or disable workout activities. To demonstrate the issue, edit a timer to continue until manually stopped by changing the Number of Cycles to "Until Stopped". Then start the timer on the watch. Let it run for a period of time to create more than 50 intervals, for example, then stop the timer. Swipe to the leftmost screen on the watch, tap pause, then tap end. At that point you'll see how slow the workout saved.
Next, you can go back to the iPhone app, disable using workout activities and repeat the test. The workout will save quickly in this case.
I've filed a feedback.
I noticied that my workout session is sometimes being killed by apple when the app is in the background and it seems that the func workoutSession(_ workoutSession: HKWorkoutSession, didChangeTo toState: HKWorkoutSessionState, from fromState: HKWorkoutSessionState, date: Date) {
is only being called when the app comes back into the foreground.
I wonder if there is a way for us to get notified when the workout is about to die or has already been killed.
Thanks
Hello, our app has been rejected in the review of version update, we need to provide relevant medical certificates. And our classification is Health and Fitness.However, our device is not a medical device and does not have a medical hardware regulatory license. How can I pass the audit?
“Hello,
The issues we previously identified still need your attention.
If you have any questions, we are here to help. Reply to this message in App Store Connect and let us know.
Review Environment
Submission ID: e5e36844-23e5-41fc-a956-eb46746728c1
Review date: April 16, 2024
Version reviewed: 1.0.1
Guideline 1.4.1 - Safety - Physical Harm
The app connects to external medical hardware to provide medical services. However, to be compliant with guideline 1.4.1, you must:
Provide documentation from the appropriate regulatory organization demonstrating regulatory clearance for the medical hardware used by the app.
Provide documentation of a report or peer-reviewed study that demonstrates the app's use of medical hardware works as described.
Restrict distribution of the app to regions where you have obtained regulatory clearance for the medical hardware used by the app. Otherwise, you must provide a jurisdiction statement in the app description declaring where the medical hardware has regulatory clearance to be used.
Update the app's description to include a disclaimer reminding users to seek a doctor’s advice in addition to using this app and before making any medical decisions.
Next Steps
To resolve this issue, provide the documentation requested above, restrict your salable storefronts in App Store Connect or include a jurisdiction statement in the app description, and update your app's description in App Store Connect to include the required medical disclaimer.
Resources
Learn more about requirements for medical apps in guideline 1.4.1.
Support
Reply to this message in your preferred language if you need assistance. If you need additional support, use the Contact Us module.
Consult with fellow developers and Apple engineers on the Apple Developer Forums.
Help improve the review process or identify a need for clarity in our policies by suggesting guideline changes.”
Could you please provide clarification on whether WatchOS currently supports the real-time or on-demand measurement of skin temperature and ambient temperature? If so, Could you also guide us on the relevant APIs or resources available for incorporating these features into out applications?
Hey!
TLDR: How Health app knows the new menstruation cycle started?
The API
Adding .menstrualFlow (HKCategoryValueMenstrualFlow) samples require HKMetadataKeyMenstrualCycleStart: Bool parameter. It's fairly simple for the consecutive days - the first sample includes true, the rest false.
The problem
What about more complex scenarios like: 3 days of unspecified samples, then 2 days of none samples, and unspecified sample again. Should it be marked as the new cycle start? I don't want to prompt the user to confirm the new menstruation cycle.
Observations
I noticed Health app performs some logic under the hood.
For instance, when I marked 5 days in a row unspecified, then left 6 days in a row empty, then selected unspecified again, I got 2 menstruation cycles (11 days ago and today).
But when I changed the number of the days I marked as unspecified before the gap, or the length of the gap, or edited the cycles further in the past, I ended up having just 1 menstruation cycle.
I guess Health app takes into consideration: previous menstruation length, gap length, average cycle length. But what is the exact math here? I don't want to ruin the user's statistics 💚
I found in the user guide this info about the fertility:
The fertile window will be the six days you're most likely to be fertile, based on data that you’ve logged about your period or a positive ovulation test result. The fertile window prediction is based on a traditional calendar method. The fertile window is calculated by subtracting 13 days (the luteal phase) from the estimated next cycle start date.
So I think something similar might be going on here.
Thanks in advance!
Hi, I am developing a service that reads data from wearable devices.
It should launch the scheduler every 15 min, but however sometimes there is a delay of 1 - 5 minutes, there are days that the scheduler does not run between 23:00 to 7 am, I am using BGAppRefreshTaskRequest.
Can someone give me a hand?
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
iPhone 15 pro max. iOS 17.4 (had to ask here because of normal discussion group rules)
This past Monday I checked my rings and they were all closed. On Tuesday I saw that my Monday rings had changed and were now not closed. The recorded data for the day should be enough to make all the rings closed, but it is acting like it reads some small proportion of the data and stops. I've not noticed this behavior on any other day in my fitness history.
The move ring stops at about 25% and reports 65/260 cal, but the data shows about the same activity as the day before and the day before closed health also shows Monday had a higher than normal active energy level. The step count is off by an order of magnitude. The recorded data clearly shows 15+ minutes of exercise, but the ring shows 1. My stand graph shows 12 hours, but the ring shows 4. (can't post images to this forum so have to describe).
Since then I have tried several things to make it recalculate the data. I've had the iPhone delete all health data and reload from the cloud 3 times. I've reset the phone to factory and reloaded from backup.
I turned back time to Sunday evening at 11:58 and let the day turn over and did the same for Monday and it keeps drawing to the same point.
I looked at the underlying data in health and nothing about the day seems strange. I tried adding 1000 extra steps to see if that would make the move ring jump any with no effect.
Any help or ideas would be appreciated since this anomaly broke my 500 day streak (at 498!)
Was sent here when I asked in the general forums and they pointed out I was running public beta, so had to ask here.