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.
Related
I would like to do some automated export location history - map (or picture of the map) of my walking and running activities from my Garmin watch.
I am not an enterprise developer, so I am not able to use Garmin API.
I am using HealthSync app to sync activities Garmin->GoogleFit.
I am able to see location trak inthe google fit.
I was trying to retrieve it via GoogleFit API, but looks like google does not allow we to do it :-( DataSource for the location in google fit Rest API
I was trying to perform sync Garmin->Fitbit (Fitbit has wonderful API)
But looks like HealthSync is not transferring location tracks from Garmin to Fitbit.
And I am near to giving up :(.
What could be an option for me to automate exporting\saving location tracks of my runs and walking?
I do like my Garmin watch and don't see good alternatives for them. But also I would like to own my data :-)
Google made some policy revisions especially with GDPR regulations tightening their nooses.
As stated in officially published docs, https://developers.google.com/fit/datatypes/location#location_sample, location data is exclusive to the application that originally wrote it. Thus, it becomes obscured to any other 3P app that also is writing and reading location data of its own.
You can also reach out to their mailing list, fit-developer-support#google.com, should you need any clarifications with their APIs, especially now that they're introducing Health Connect to replace the Android APIs, https://developer.android.com/guide/health-and-fitness/health-connect
Are there any third party which provide data of apple health kit data using there end points like google fit provide us via rest api's https://developers.google.com/fit/rest/v1/get-started
No, there are not.
And there most likely won't be in the future either. This is an easy conclusion to make given how Health Kit integration works today and how Apple has privacy protocols around Health Data -
Integrating Health Kit in your app allows you to see Health Data only after the user has granted relevant permissions (of course). But the user has to explicitly grant permission for each datatype (HKObjectType) eg sleepAnalysis, blood glucose etc.
Your app with Health Kit integration can only request Health Data while the app is active in the background and the phone is not locked or running in the foreground. So lets say you have background tasks (BGAppRefreshTask or BGProcessingTask) to request Health Data - this won't work if your phone is locked.
Given these behaviours and other restrictions Apple places around the use of HealthKit, I don't see how there is ever (or at least in the near future) going to be a an api to relay this data.
If you absolutely had to it, your best bet would be to write an application on the device that integrates with HealthKit and exports HealthData to your servers. Then explicitly prompt the user to export HealthData from the app every time, and expose an api from your server. Not happening.
I'm doing research for an app I have to build for our start-up.
I want to build an app that keeps count of the steps a person takes every day by using HealthKit on iOS.
When the user requests a refresh or restarts the app, I can request the latest step count available. However, we want to push notifications to the user as soon as they have taken a set amount of steps (10,000 for example).
So I was wondering if I could set up a listener within flutter, so that HealthKit would (battery efficiently) provide the latest step count as they come in or at a set value/interval.
Is this 'listener'-architecture that communicates between flutter and native Swift code possible with flutter, and if so, is it the best approach?
Is the same also possible on the Android side?
Thank you for your attention.
Perhaps HealthKit's or HKObserverQuery is what you need on the iOS side
Receiving Background Deliveries
Apps can also register to receive updates while in the background by
calling the HealthKit store’s
enableBackgroundDelivery(for:frequency:withCompletion:) method. This
method registers your app for background notifications. HealthKit
wakes your app whenever new samples of the specified type are saved to
the store. Your app is called at most once per time period defined by
the frequency you specified when registering.
As for architectures that
communicates between flutter and native Swift code ... Is the same
also possible on the Android
I believe you are looking for Flutter Platform Channels where you can find a Swift Example.
Flutter uses a flexible system that allows you to call
platform-specific APIs whether available in Java or Kotlin code on
Android, or in ObjectiveC or Swift code on iOS.
Flutter’s platform-specific API support does not rely on code
generation, but rather on a flexible message passing style:
The Flutter portion of your app sends messages to its host, the iOS or
Android portion of your app, over a platform channel.
The host listens on the platform channel, and receives the message. It
then calls into any number of platform-specific APIs – using the
native programming language – and sends back a response to the client,
the Flutter portion of your app.
Unfortunately, I don't see any existing Flutter HealthKit but hopefully the available tools are enough to let you build your own bridge for HealthKit.
Brandon Donnelson's Video on Creating a Plugin may also help.
I am not sure if there are HealthKit alternatives to Android.
Can my app fetch HealtKit data from third party devices? For example from Garmin? In HKSource documentation, it seems that user would have to use Garmin app to transfer HealtKit data from his/hers device to iOS device and only then my app could use that data:
devices need a companion app to collect and save the data to
HealthKit.
Or can I write app, that would handle fetching data from 3rd party devices?
tl;dr Can my app get HealthKit data from 3rd party devices
Third party developers can provide import functionality to health app via the normal Health Kit API on iOS.
Some apps scrape or use web API such as Sync Solver exist to get FitBit data from the cloud to the local health app on iOS. Some such as Health Importer are more general. (proper disclosure: I work on this app)
We have an app on the store that is designed specifically for importing arbitrary CSV data into HealthKit / Health.App.
i hope without API you can't do this.
I have an app which reads data from Strava, Runkeeper and couple of other health apps.
Now I am planning to integrate HealthKit in my app and read data from there as well.
My concern is data duplicity. i.e. say Strava sharing same data to my app and Healthkit, and then my app updating same data from HealthKit.
Not sure if this is allowed due to privacy concerns or not, Is there any way my app can know what all apps share data with HealthKit, preferably date range and type of data as well.
OR
Do I need to build the comparison logic in my app itself to detect duplicate data based on date and actual data?
The best way to do this with the HealthKit API is to simply not process data that comes from providers that your app can already integrate with. Every HKObject has an HKSource property, and that HKSource will give you the bundle identifier of the application that created it. You can use this to create a blacklist of sources to reject from HealthKit.
HealthKit framework is a centralized store for health data among various applications with in the iPhone device. So, all the health apps can share health data with HealthKit store.
For your case, there may be possibly 2 solutions available.
Simply stop updating health data from all other health apps like Strava, RunKeeper, etc., and read same information from Apple's HEALTH app to avoid duplicate records.
Read health data from all other health apps which you would prefer and omit the health data fetching from Apple's HEALTH app, which was entered from Strava, RunKeeper, etc., Sample to get the health data based on source is https://stackoverflow.com/a/29346592/1295573
Yes you can do this with health kit.
The HealthKit store provides a number of methods for accessing its data.
Direct method calls
Sample query
Observer query
Anchored object query
Statistics query
Statistics collection query
Correlation query
Source query
For more details go through https://developer.apple.com/library/ios/documentation/HealthKit/Reference/HealthKit_Framework/..
let me know if you get stuck somewhere.. :)