This question already has answers here:
How to get sensor data from Apple Watch to iPhone?
(2 answers)
Closed 7 years ago.
I'm reading several articles and Apple's documents regarding Apple Watch and WatchKit development. It looks like third-party apps for Apple Watch like Strava and Runtastic will need you to also carry your iPhone while doing exercise to take and show data (as described in App Store Apps), but I don't find if the built-in apps (Activity and Workout) will also need it. It looks a bit uncomfortable having to carry your iPhone while running to be able to see your heart rate, speed and so on in the watch...
Regarding the data measured by the heart rate sensor and accelerometer integrated in the Apple Watch: is there an API that makes them accessible to third-parties developers?
And how is data mesaured by those sensors handled by the watch: is it directly sent to the paired iPhone as it is measured? It is temporarily and locally persisted in the watch until it is possible to send it to the iPhone? Is HealthKit available for WatchKit apps to handle such information?
Thanks in advance
Watchkit Sensor raw data information is now accessible with WatchKit for watchOS 2.0.
WatchOS 2 includes many enhancements to other existing frameworks such as HealthKit, enabling access to the health sensors that access heart rate and health information in real-time.
You could check this information in the following session which is total 30 minutes presentation. If you do not want to watch entire session, then you directly jump to Healthkit API features which is in between 25-28 min:
WatchKit watchOS 2.0 Session in WWDC 2015
I played with the Apple Watch at the Apple Watch lab.
The sensors and accelerometer are not accessible to devs.
You can go running without your phone and when you get home the heart rate data will 'eventually' be sent to Health on your phone, from which you can query data for your app. Any heart rate or sensor data saved on the Apple Watch cache is not accessible to dev.
Related
Last year I built an iOS application that reads in workouts from Healthkit. These workouts were recorded by the Apple Watch in built fitness application and gathers heart rate information using photoplethysmography (the light sensor in the watch before the ECG).
I want to get the new Apply Watch with the ECG monitor. If I record a workout in the same manner as above, will the data from the ECG still be passed into Healthkit and will my mobile application therefore be able to read the workout from Healthkit and all the relative heartrate data?
I'm hoping I don't need to perform any updates on my mobile application now that the apple watch has an ECG and not the photoplethysmography.
Does the new Apple Watch come with both photoplethysmography and the ECG or just the ECG?
As of iOS 14 and watchOS 7, you can now read an ECG sample as an HKElectrocardiogram.
https://developer.apple.com/videos/play/wwdc2020/10182/?t=105
I am trying to export the health data from my iPhone/Apple Watch automatically. I know it is possible to export the data manually by opening the Health app on your iPhone > clicking the user icon > "Export Health Data". However, I would like to do this automatically and periodically to analyze the data (heart rate, steps, etc.) externally in Python. Is this possible at all?
To access any of your health data stored in Apple Health, you need to add the HealthKit framework to your iOS app by enabling HealthKit capabilities in Xcode. By using certain methods you can request permission from your iPhone to read and write data with your app.
To actually get the data you need to access it by using direct method calls, queries, or long-running queries – depending on how you want to retrieve the data and how background retrieval might work.
There is an "Apple Native way" to do that, This link has a comprehensive step-by-step guide (mainly but not exclusively for iOS developers). The drawback is that you can only integrate HealthKit into iOS applications and need to use iOS SDK 8 or higher.
In my workout app, my users are typically away from their iPhone during their workout. I understand that with the new Series 3 Apple Watch + LTE this isn't an issue, however for Series 0 through Series 3 (WIFI only), does Apple take care of logging the data on the watch, and more importantly if my user saves his/her data into HealthKit with no WIFI available and the iPhone out of reach will it sync up and save the workout when the iPhone is back within range? If not, what can I do avoid losing user workout data other than not permitting a save to be available unless the iPhone is within range?
If all of your data is stored in HealthKit, you don’t need to worry about this. HealthKit data will sync when the devices are connected.
You can save the data in the documents directory just like on the iphone and synch it when the phone is available. Apple has documentation on all the ways you can share data here. For instance you can use transferFile(_:metadata:) to send your watch file over to the phone int he background.
Is it somehow possible to get live stats from the Apple-Watch about the users heart rate? Currently I only get callbacks on the watch as long as the app is open and the screen is active. Then I can send them to the Phone using the WCSession.
But having live stats on the phone without the watch being turned on is not possible, right?
I would have to query the HealthStore after the workout is completed? And how long would I have to wait on the phone after finishing my workout on the Watch for the Heart-Rate data to be synced?
What would be the best practice to add heart-rate data to my GPS trackpoints that I record? Just query the HealthStore some time after the activity and try to match the points by timestamp?
Any advice or tipps are very welcome :)
If you start a HKWorkoutSession on your Apple watch results are written to HealthKit in 5 second intervals (even if the watch screen is off). This data is automatically synced by Apple with your iPhone in the same 5 second intervals. If you create a health kit streaming query on your iPhone, you should be able to get "near live" stats. Take a look at this answer for more details on how to create a streaming health kit query.
Apps on watchOS may only run when the screen of the watch is on so practically speaking there is no way to reliably stream data, like the user's heart rate, from the watch to an app on the phone.
When the app on the watch does get an opportunity to run, it can collect heart rate samples from HealthKit and send them to the companion at that point.
Displaying live heart rate statistics on the phone is not possible because your app cannot control how frequently data is synced from the watch to the phone.
If I understand it correctly, HealthKit can automatically connect with bluetooth accessories of the following types - heart rate monitor, glucose sensor, blood pressure monitor, health thermometer.
There is no need to have companion apps for them as they can write the data directly (and of course wirelessly) to HealthKit.
I am just curious if it is true and if so do all these accessories work seamlessly with HealthKit. Is no configuration needed. Has anyone tried it.
Further there are some accessories (such as the iHealth blood pressure monitor) which do the measurement only once the measurement is initiated from the companion app. So how do those tie-in.
As of iOS 8, the system can import data from a BTLE heart rate monitor directly into HealthKit with no companion app. This can be configured in the Bluetooth settings pane of iOS.
There is a WWDC video that goes into more detail about this available here. Also, if you have an idea for a HealthKit accessory that is not supported currently, you should contact Apple with this form.
Despite what was said during WWDC 2014, it appears only Heart Rate is available.
From HKSource Class Reference:
Source objects represents the different data sources in HealthKit. These sources may include apps and devices whose data can be directly imported into the HealthKit store. Currently, HealthKit supports only the direct import of heart rate data from Bluetooth LE devices. All other devices need a companion app to collect and save the data to HealthKit.