To get your own and shared data with HealthKit programmatically, you need to request permission to read the right data types through HKHealthStore, then run HKSampleQuery without predicates to get all the samples, and check the data source through HKSource to distinguish who provided them. Do not forget that the user must authorise access to this data.
Topic:
App & System Services
SubTopic:
Health & Fitness
Tags: