Query HealthKit for list of existing WRITE permissions? - ios

I understanding from the WWDC video that the HealthKit API does not allow apps to query what measures they are allowed to read, but I was under the impression the Health Kit API does allow users to query Health Kit for what kinds of data they are allowed to write. However I have not been able to find the command to do this. Where is this info listed in the docs? Thanks for any suggestions.

You can determine your app's authorization status by calling authorizationStatusForType: on an HKHealthStore instance. See the documentation here

Related

Automatic export location tracks of walking\running activiies in garmin

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

Apple Health Kit Data via Rest API

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.

Apple Watch - Example on how to get heart rate data?

Apple recently made heart hate raw data avaliable through healthkit, but the documentation is very confusing and I can not understand exactly how to measure the heartbeat of someone wearing the watch. I could not find any good examples on the internet either, so I'm hoping that someone could help me understand how can I get these values in a easy way.
The key is to check out HealthKit, not WatchKit. From the docs:
Setting Up HealthKit
Before you can begin using HealthKit, you must perform the following steps:
Enable the HealthKit capabilities in Xcode.
Check to see whether HealthKit is available by calling the isHealthDataAvailable method. HealthKit is not available on iPad. Additionally, HealthKit can be disabled on other devices—for example, iPhones that are provisioned for schools or corporate environments.
Instantiate an HKHealthStore object for your app. You need only one HealthKit store per app. This store acts as your primary interface with the HealthKit database.
Request authorization to access HealthKit data using the requestAuthorizationToShareTypes:readTypes:completion: method. HealthKit requires fine-grained authorization. You must request permission to share and read each type of data.
Etc....

HealthKit data duplicity concerns

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.. :)

Is there an API for Frequent Location History on iOS?

I noticed "Frequent Locations" while rummaging through my settings on my iOS device. I'm trying to build an app that basically combs through your location history, either by social network or by your device, and determines if you were at a particular event. Does apple provide an API to access your recent frequent locations on your device? I read through this documentation but didn't see anything about location history.
From reading the Apple API reference guide it looks like 'locationmanager(_:didVisit:)' would provide the information you're looking for. It would provide data on locations that the user was in for a extended period of time.
What Apple's definition of extended is, I'm not sure. But this should get anyone searching for the frequent locations data a bit closer than what was posted in response to this question.
In the 'Getting the Visited Locations' subsection of this link.
https://developer.apple.com/reference/corelocation/cllocationmanager

Resources