Reputation: 7207
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?
Upvotes: 1
Views: 2108
Reputation: 908
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.
Upvotes: 3
Reputation: 1483
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
Upvotes: 0
Reputation: 3607
Yes you can do this with health kit.
The HealthKit store provides a number of methods for accessing its data.
For more details go through https://developer.apple.com/library/ios/documentation/HealthKit/Reference/HealthKit_Framework/..
let me know if you get stuck somewhere.. :)
Upvotes: -1