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.
Related
I searched everywhere but I don't find any proper answer related Watch App.
So, my question is Can I fetch Calories and Steps real time to update my app from Watch app?
Is there any way to keep my app up to date of Calories and Steps?. Also there any way I get directly steps and calories from watch app to my app without watch app?
I know I can get steps and calories from Health kit but its not real time they will update in sometime.
You can use CMPedometer to get more real-time steps data. Note that this is data that is generated on the watch and will not include any steps data synced from phone (HealthKit will consider both data streams in its results). Calorie data is only accessible through HealthKit.
Is it possible to read/sync the Heart Rate data from Apple watch series 3 without creating a watch app?
I want my iPhone app to read data directly from the Apple Watch without having to create an app for the watch too.
Apple Watch syncs all of its recorded heart rate data (automatically sampled every five minutes while wearing, and more frequently during workout sessions) to the HealthKit store on the companion iPhone.
So you can create an iOS app that (with the user's permission) reads the stored heart rate data using HealthKit. The gist of it:
Set up your project for HealthKit support in Xcode's Capabilities pane (part of your app target settings).
Check for HealthKit availability on the device (HKHealthStore.isHealthDataAvailable()) and create an HKHealthStore object.
Verify that you have user permission to access heart rate data:
let heartRateType = HKObjectType.quantityType(forIdentifier: .heartRate)!
healthStore.requestAuthorization(toShare: nil, read: [heartRateType], completion: myHandler)
After that completion handler reports success, use HKSampleQuery to search for the most recent heart rate sample, a set of heart rate samples within a specified time frame, etc. (Or other HKQuery subclasses for things like average heart rate over time, etc.)
If instead what you're asking is for a way to read the user's current heart rate "right now" from an iOS app, without creating a companion watchOS app... no, there's not a way to do that.
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.
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.
AIM: I am trying to integrate my iPhone app with a bluetooth device that can play music and display some visualisation (yet to choose bluetooth hardware). There are three things that puzzles me:
I have seen some sample programs that generate visualisation data based on averagePowerForChannel using AVAudioPlayer. Is it possible to extract such information for a music stored in iPhone filesystem without actually (or before) playing the music? Since iPhone apps cannot execute in background infinitely, extracting this data realtime may not advised?
Once I create this "visualisation" data for an mp3, can how can I send the data to my bluetooth device? I know we can sent custom data only via BLE. Is there a possibility that I can send music data and visualisation data to the bluetooth device at the same time?(or sent visualisation data for a few seconds first and then start streaming the music) - This advice will help me to choose a proper hardware, provided iPhone supports this!
If I cannot sent music data and visualisation data at the same time over bluetooth, I am planning to extract visualisation data first from the mp3(how?), send it over to be stored in the bluetooth device and then display accordingly, in sync with the music data received in real time. Is this possible?