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.
HealthKit
RSS for tagAccess and share health and fitness data while maintaining the user’s privacy and control using HealthKit.
Posts under HealthKit tag
93 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
With the recent iPad OS 17 release, Apple added the Health app for the first time. Looking at it, it seems pretty similar to the phone version as the Health app only shows 'historical' health data.
My question is this: We are developing an iPad based fitness app. Is there any way of getting real-time health data from the Apple Watch directly to an iPad app? (basically, we just need heart rate). Or, do we have create some sort of workflow through the Phone like
Watch -> iPhone running our app -> our servers -> iPad running our app
..to get that real-time data?
We really just want Watch -> iPad running our app.
I'm afraid I already know the answer but just thought I'd check in case I'm missing something in iOS 17.
Thanks!
Our app uses HKWorkoutSession after some actions, to keep app on high priority in background and to keep Apple Watch returns to our app when the watch is waked up. We don't collect or register any activity record.
But for some reasons, some users reviewed our app saying that when they're using our app, the Workout app on Apple Watch seems to be affected, ex: Move and exercises is recorded as an abnormal/impossible value... .
Is this possible? I don't see any document mention this side effect?
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?
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
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.
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?
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 :)
I would like to create an Apple Watch only app that queries data such as blood oxygenation, heart varibility, number of steps, energy consumed, and other data of a similar nature recorded over the past month and performs calculations on them. I read from the HealthKit documentation that Apple Watch synchronizes data with iPhone and periodically deletes older data, and that I can get the date from which the data is available with earliestPermittedSampleDate().
Is there a risk that in general, by making queries to retrieve data up to a month old, the data will no longer be available?
I need the app to work properly without needing an iPhone.
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.
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!
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
I developed an iPhone/Watch app with the single target setting (new method) for Watch app projects, which will be available from Xcode14. This app uses HealthKit to retrieve information such as step count and heart rate from healthcare. The watch app is not independent and requires the iPhone app (companion app).
Regarding the permission to access health care, i found some differences from the Old WatchApp Project (application project structure using WatchExtension when Xcode 13.4 or lower is used).
This does not occur in the iPhone simulator or watch simulator, but only on the actual device.
Both the iPhone app and watch app now display a dialog to allow access to health care
In the Old WatchApp Project, if access was granted in either app, the granted access is synchronized.
When checking the Health Care access status in the iPhone Settings App, permission settings for both the iPhone app and watch app are displayed independently.
Because each permission setting is independent, you can choose to allow access to the iPhone app but not to allow it to the watch app.
the Old WatchApp Project, permission settings for the iPhone app and watch app were synchronized, so it was not possible to have different settings for each.
These behaviors are not described in the documentation.
It would be understandable if the transition from watch "extension" to watch "app" is to split the app into two separate units.
However, since there is no official documentation explaining this, i cannot determine whether this is the correct specification or not.
Furthermore, since the companion app is required rather than a separate Watch app, having the Health Care permission settings out of sync with the companion app could cause unexpected problems and worsen the user experience.
(It would be difficult and cumbersome for the user to know what settings they have made).
Is there a solution to synchronize this behavior with the companion app like as the Old WatchApp Project?
Do i have to go back to the project configuration (use of watchExtension) before Xcode13?
I have prepared a sample project below that can test the above.
https://github.com/HayakawaAKIRA/SingleTargetWatchOSApp-HealthKit
reference:
https://developer.apple.com/videos/play/wwdc2022/10133/
https://developer.apple.com/documentation/watchkit/wkapplication
https://developer.apple.com/documentation/healthkit/setting_up_healthkit