I am creating a watchOS app with XCode, and am experiencing an issue where workouts do not start on watchOS versions 9.6.3 and later.
・App specifications
Start workout when app starts
code (swift)
workout?.startActivity(with: Date())
·phenomenon
In watchOS version 9.6.3 or later, after the Apple Watch runs out of battery or is turned off.
When you turn on your Apple Watch and start using it, even if you start a workout (startActivity),The status may not change to running and the workout may not work.
*Workout always worked on watchOS versions earlier than version 9.6.3.
*The workout will work if you close the app and start the app again.
If anyone has any information, please provide it.
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
As the title says, I logged in to iCloud on my simulator on my mac mini m2 and turned on icloud sync. My health data is in iCloud but it wont load in. When I go to documents for example I can see documents that I have loaded so I know something is working right.
I have tried clicking Feature -> Trigger iCloud sync with no luck.
I have tried logging out and logging back in, no luck.
I have tried Restarting the simulator with no luck.
The app I am building uses health data and there is no other way to get health data (heart rate, workouts, sleep) in the simulator. Please help, Thank you
Hi,
My app reports daily step counts, and I’m trying to use HKCumulativeQuantitySample to report them to HealthKit by adding such objects with each update:
let sample = HKCumulativeQuantitySample(type: .stepCount, quantity: HKQuantity(unit: HKUnit.count(), doubleValue: dailyTotal), start: startOfDay, end: nowDate)
However, HealthKit interprets them as regular samples—it sums them into a global aggregate instead of updating the daily cumulative value. So if I report the daily step count as 500 and then 550, HealthKit interprets it as 1,050 steps instead of 550.
Is this expected behavior? If so, what is HKCumulativeQuantitySample intended for, and how should it be used? I’m struggling to find any examples.
Thank you
WorkoutKit WorkoutScheduler seems broken with the first beta of iOS 18.2.
I have tested using my app from Xcode and the one that is on the App Store (and working properly on other devices), and it's not working with this new beta of iOS.
They appears in WorkoutScheduler.shared.scheduledWorkouts, but not on the watch.
I even tried with other apps that do the same with
Manual add to Apple Watch with SwiftUI workoutPreview work.
Xcode 16.0
iOS 18.2 Beta 1
WatchOS 11.1
I'm currently trying to collect some of the following data whilst running a workout in a WatchOS app I'm building. Below are the data points I'm trying to retrieve:
HKQuantityType.init(.heartRate)
HKQuantityType.init(.oxygenSaturation)
HKQuantityType.init(.respiratoryRate)
HKQuantityType.init(.bloodPressureSystolic)
HKQuantityType.init(.bloodPressureDiastolic)
HKQuantityType.init(.heartRateVariabilitySDNN)
I'm using the following delegate function workoutBuilder(_:didCollectDataOf:) which is part of HKLiveWorkoutBuilderDelegate
Something I'm realising whilst running this on the simulator and on my Apple Watch is out of all of the Quantity types I'm requesting. Only the heart rate is being called via the delegate function when trying to retrieve the statistic.
Is this the intended behaviour of this API? Since there's no docs about what is and isn't exposed
As the title says, I logged in to my simulator on my mac mini m2 and turned on icloud sync. My health data is in iCloud but it wont load in. When I go to documents for example I can see documents that I have loaded so I know something is working right. I have tried clicking Feature -> Trigger iCloud sync with no luck. The app I am building uses health data and there is no other way to get health data (heart rate, workouts, sleep) in the simulator. Please help
Hello everyone,
I’m experiencing ongoing issues with my app’s review process. The app is being rejected under Guideline 1.4.1 (Safety - Physical Harm), and the reason provided is that it doesn’t include appropriate citations for health and medical recommendations.
This app is designed for qualified nutritionists to create personalized meal plans for clients. All recommendations are based on data provided by the client and supported by dietary guidelines from recognized organizations.
We’ve already included multiple citations to credible sources such as:
• USDA
• NIH
• WHO
• University of Oxford
• The Nutrition Source
• ResearchGate
• PubMed
• EUFIC
• DGE
• EFSA
These citations are clearly listed, and all recommendations come from nutritionists with degrees from accredited institutions. Despite this, the app continues to be rejected under 1.4.1. After asking the reviewer for clarification and providing detailed explanations, they’ve stopped responding and only send the same automated response referencing 1.4.1.
Additionally, the client profiles in our app are created via an Admin platform. Should data like height, weight, and other physical metrics be visible in the user’s profile to meet review requirements? We’re wondering if the lack of visible user metrics could be causing this rejection.
Has anyone experienced similar issues or have advice on how to resolve this? We’re uncertain what more we can do at this point and would appreciate any guidance.
Thanks in advance.
I´m working within the health felid with a few apps. Accordingly to science one of the most important parts to keep healthy is every day walking.
But it is not to walk slow. You need to come to a little speed (not running or even jogging). But to rais your puls. This is when you get the "real health effect". In general it is around 6km/h.
It would be great if apple could make this info available for us developers. I think lots of developers will be happa and use this to make better apps and get more people in a healtheyer life.
Looking forward to get some feedback on this.
Thank you!
Cheers
Peter
In this link, Apple states we can know when a user is in bed vs sleeping and compare their quality of sleep by it. Only, in iOS 18, Apple no longer reports inBed time samples for the Apple Watch. I get why they stopped doing this for the phone, but why the watch? Bug?
My app was using the inBed times for this very purpose and now only works for Garmin and Oura who still report inBed times.
https://developer.apple.com/documentation/healthkit/hkcategoryvaluesleepanalysis
Hi,
In Apple Health, when there is an entry for a visit with a doctor, many times there are accompanying PDFs that are loaded into Apple Health along with the numerical/text data. Is there a way to pull PDFs into an app as well as the numerical/text data?
Thanks
I have FB12696743 open since July 21, 2023 and this happened again today.
I get home at approx 10 mins after the hour, walk appox 50 ft across my yard, up 5 steps into my house, let the dog out and pace on my deck watching the dog, go back in the house walk around the kitchen while preparing dinner. A total of about 200 ft. I sit down about 35 past the hour and start to eat and at 10 mins to the next our and I get the reminder to stand.
On the other side I wake up at 5 mins to hour. Walk 8 steps to the bathroom and successfully achieve the stand for that hour.
WHY!?!?!? 😁🤣
Hi everyone,
I am trying to send a request to my server in my watch application when HKObserverQuery is triggered. This is working fine when my app is in foreground however the request is not sending when the app manually terminated or in background. HKObserverQuery works fine and triggered in these cases however the request is not sending. I researched about URLSessionConfiguration.background and background sessions but I could not figure it out. I don't want to download or upload a file, I just want to send a simple request when HKObserverQuery is triggered.
Can you show me to a path way to make it possible?
I am trying to test my watch app with my iPhone, I am assuming the behavior of these scenarios might be same in both device, am I correct?
let urlsession = URLSession(configuration: URLSessionConfiguration.background(withIdentifier: "enablement"), delegate: self, delegateQueue: nil)
let dataTask = urlsession.dataTask(with: urlRequest)
dataTask.resume()
As shown in the code snippet, I tried to set background configuration to my URLSession.
I enabled background fetch in background modes.
Apple documentation says, dataTask can not run in background -> https://developer.apple.com/documentation/foundation/urlsessiontask However I don't want to perform a long running task such as downloading or uploading.
I've realised with the sample code from the WWDC video below I'm getting the following error when trying to use the iPhone simulator and apple watch simulator paired.
Whenever i try to test out the sample project I'm getting the following error.
Failed to send data: Error Domain=com.apple.healthkit Code=300 "Remote device is unreachable" UserInfo={NSLocalizedDescription=Remote device is unreachable, NSUnderlyingError=0x600000c9c900 {Error Domain=RPErrorDomain Code=-6727 "kNotFoundErr ('rapport:rdid:PairedCompanion' not found)" UserInfo={cuErrorDesc=kNotFoundErr ('rapport:rdid:PairedCompanion' not found), cuErrorMsg='rapport:rdid:PairedCompanion' not found, NSLocalizedDescription=kNotFoundErr ('rapport:rdid:PairedCompanion' not found)}}}
Is it not possible to not test out the new WorkoutKit mirroring API's using the simulator?
Currently right now if you run the project you'll notice that you can start a workout session on the iPhone > Apple Watch but there is no way to control and mirror on both devices at the moment i.e You can't control the iPhone app on the Apple Watch and vice versa.
Also because of this the iPhone can't send data to the Apple Watch i.e. pause, end, water etc. I'm guessing this is meant to be possible since it seems a bit strange to only be able to test this out with actual devices.
WWDC Session
https://developer.apple.com/wwdc23/10023
Sample Code
https://developer.apple.com/documentation/healthkit/workouts_and_activity_rings/building_a_multidevice_workout_app
Im building a workout app to track swimming workouts for watchos 11. Triggering .prepare() on my HKWorkoutSession does not change the session state HKWorkoutSessionState.
Below is my prepare function which should transition the session state to HKWorkoutSessionStatePrepared. Nothing is thrown in the delegates, the state just wont change? I have tried erasing, restarting, use another version of xcode and another simulator runtime.
func prepare() {
guard self.session == nil else {
fatalError("Session already exist")
}
// Configure Workout Type
let config = HKWorkoutConfiguration()
config.activityType = .swimming
config.swimmingLocationType = .openWater
config.locationType = .outdoor
self.Workoutconfig = config
// Create Session
do {
guard store.authorizationStatus(for: .workoutType()) == .sharingAuthorized else {
fatalError("Lack of permission to start workout")
}
let session = try HKWorkoutSession(healthStore: store, configuration: config)
self.session = session
self.builder = session.associatedWorkoutBuilder()
Logger.diveController.info("Successfully created workout session")
builder?.dataSource = HKLiveWorkoutDataSource(healthStore: store, workoutConfiguration: config)
self.session?.delegate = self
self.builder?.delegate = self
if self.session == nil {
fatalError("No workout session created")
}
if self.builder == nil {
fatalError("No workout builder created")
}
self.session?.prepare()
logger.debug("Session Started at: \(self.session?.startDate ?? Date())")
logger.debug("Session State: \(self.session?.state.description ?? "")")
if self.session?.state != .prepared {
reset()
fatalError("Failed To Prepare")
}
} catch {
Logger.diveController.error("Error starting workout session: \(error.localizedDescription)")
}
}
Hi,
I am using HealthKit for the first time.
I am using HKStatisticsCollectionQuery.
I am running my code iOS 17 on a physical iPhone.
It takes several seconds to query data, for example 1 day worth of heart rate at 1 minute resolution. I changed the resolution to 1 hour, expecting it to be faster, but it's pretty much the same…
I have been following the official documentation and sample code.
I also compiled in Release, but that didn't really help for HKStatisticsCollectionQuery.
I quickly looked with Instruments, the app is spending a lot of time in decoding data with NSXPCDecoder.
Is there a way to speed data retrieval? Or this is "expected" latency?
I bought my phone on April 1st week, 2024. In September battery was 96% cycle count 260. Now after 1 month battery health is 90% in cycle count 300. I am using my phone everyday4-5 hours and maitaining 20-80 charging. I didn't play any kind of games in my device. My question is why apple claim 1000 cycle count and 80% will be? And how to solve this issue?
Hey I'm a college student and I'm open to apple for product testing in real time willing to test the new apple watch series line up. If anyone's willing to contact please let me know
Finally at last Apple Health supports saving .distancePaddleSports, .distanceCrossCountrySkiing, .distanceRowing, .distanceSkatingSports, and much more.
The backstory. In the land of 10,000 lakes, there hasn't been a way to save 'canoe' or 'kayak' distance and I've been asking for it for years. Thank you health team for adding it this year!
FB7807993 - Add HKQuantityTypeIdentifier.paddleDistance for canoeing, kayaking, etc type workouts (June 2020)
Prior we could just save the totalDistance to a workout, but since the HKWorkout initializers were deprecated we no longer have a supported way to save these distances in our workouts. The iOS 18 / watchOS 11 introduction addresses this. If you want to know more why you can't do this in earlier versions you can check these feedback titles:
FB10281482 - HealthKit: Deprecation of totalDistance on a workout session of paddleSports breaks apps that used that to save distance to the workout because there is no "paddleDistance" type available to save as sample data (June 2022)
FB12402974 - HealthKit: Deprecation of HKWorkout completely breaks support for third party fitness apps from saving non-standard workout distance (June 2023)
Great, so there is new support that solves all of these requests and issues for the new version of the OSes. However, the downside is now that there is not much for documentation. Unlike the .runningSpeed and .runningPower introduced in iOS 16 / watchOS 9, none of the new iOS 18 / watchOS 11 types have documentation, at all. To some degree this is understandable, but types from last year still remain undocumented too.
Without this information for the data types introduced in both iOS 17/18 and watchOS 10/11 it makes building and integrating with these new types difficult to say the least. We can't make assumptions about anything.
Can we get a documentation update for new (and existing) quantity types for when Apple Watch will automatically generate samples?
FB14236080 - Developer Documentation / HealthKit: Update documentation for HKLiveWorkoutDataSource typesToCollect for which sample types are automatically collected by watchOS 10 and 11 (July 2024)
FB14942555 - HealthKit / Documentation: App Update Release Issue - HKQuantityTypeIdentifiers are missing documentation describing when the system automatically adds data (today)
I know that the behavior has changed from release to release for some of these types, so documentation would be based on OS version. If you didn't catch it, watchOS 11 will now associate .cyclingSpeed for cycling workouts both indoor and outdoor.
FB12458548 - Fitness: Connected cycling speed sensor did not save samples to health via cycling workout (June 2023 - received reply that only saved for indoor cycling, but not documented otherwise)
FB14311218 - HealthKit: Expected outdoor cycling to include .cyclingSpeed quantity type as a default HKLiveWorkoutDataSource type to collect (July 2024)
To the other third party fitness apps out there, how are you managing the knowledge of which devices collect which data types on which versions of the OS?
Sure, we could look at the HKLiveWorkoutDatSource and inspect the typesToCollect property across a bunch of devices, but again that is trial by error not 'as documented'. Is the behavior of simulators guaranteed to match the behavior of real devices? Maybe, but also maybe not.
Fingers crossed for a nice documentation update to spell out all of the behavioral details.
Apple folks / DTS, many of the above feedbacks are addressed and I plan to update or close them after the releases this fall. Some are still outstanding.
P.S. I hope that .paddleSports gets deprecated and split into individual activity types like skiing did years ago. Their MET scores are different according to the research on the physical activity compendium site.
FB7807902 - Split HKWorkoutActivityType.paddleSports into their own activity types (June 2020)
I am having trouble finding clear information about this. I want my app to collect and aggregate user data to provide useful analytics to the user and userbase. Can data accessed from HealthKit be stored on a database outside the Apple ecosystem and used for analytics?
The data will not be used for marketing and will not be shared. It will be used only for the benefit of the user's understanding of their health and for the community that uses the app.
If not, what if the data is anonymized first before being exported to a 3rd party database?
Is there anywhere that describes in detail how third party workout apps can use the new effort score functionality? I can't see much in the documentation or any of the WWDC videos.
In particular it would be useful to know if an effort score is automatically calculated for workouts created with third party apps? It doesn't seem to happen but some people say it takes weeks / months before watchOS starts calculating it for third party apps.
If it doesn't happen automatically then how can the app set it? I tried the new relateWorkoutEffortSample API but that didn't work for me (see https://developer.apple.com/forums/thread/763539).
If I could get it working then how should I determine a default effort score based on the workout metrics? Is that something that the app should do? If so then it would be good to be consistent with watchOS so some idea of how that is calculating effort scores would be useful.
Sorry for all the questions, especially if there is an article in the documentation or a video that I have missed.