Questions tagged [hksamplequery]

HKSampleQuery is an API included in Apple's iOS HealthKit framework that provides a way to search for specific aspects of a user's health data.

From Apple's documentation:

HealthKit uses sample queries to search for sample data in the HealthKit store. You can use sample queries to search for any concrete subclasses of the HKSample class, including HKCategorySample, HKCorrelation, HKQuantitySample, and HKWorkout objects.

59 questions
1
vote
2 answers

HealthKit cannot read steps data

I'm working with HealthKit to read steps data from my iOS device. here is my code: if ([HKHealthStore isHealthDataAvailable]) { __block double stepsCount = 0.0; self.healthStore = [[HKHealthStore alloc] init]; NSSet…
Cokile Ceoi
  • 1,326
  • 2
  • 15
  • 26
1
vote
3 answers

Running Some Code Multiple Times Asynchronously With Different Variables

So, I am trying to get my app to read in HealthKit data. I have a function that I call from the main app view controller which causes a query in another class for all the health data in that month. Theres then a few calculations before the array of…
Simon
  • 304
  • 2
  • 17
1
vote
1 answer

Adding HealthKit Data into one value

I am using HealthKit to make a sample query data such as the step count. However, when I test it on my device I get a bunch of different results. Now since I have the results from different sources and different days such as [16 count, 50 count,…
Harish
  • 1,374
  • 17
  • 39
1
vote
1 answer

Restrict HKSampleQuery results to those input from your own app

I wish to restrict results returned from a HealthKit HKSampleQuery to those that have been input through my own app. Is there a way to specify results only with my application bundle identifier, and thereby exclude any other data sources returned…
1
vote
2 answers

Does HKAnchoredObjectQuery automatically cache anchor?

Neither class reference nor any tutorial available online say anything about caching anchors between application runs. I want to query data between app runs so I get all historical HealthKit entries. At first, I thought I'd need to store last query…
cojoj
  • 6,405
  • 4
  • 30
  • 52
1
vote
2 answers

Accessing Health Kit data into Apple Watch OS 2 excluding Workout Data

I am able to access Workout data using workout session but unable to do the same with others such as accessing Height,Weight,Dietary Water, Body Temperature,Blood Pressure etc. Also i am able to access heart rate but unable to access body temp. Both…
Dheeraj Singh
  • 5,143
  • 25
  • 33
1
vote
1 answer

Apple Health Kit Error Domain=com.apple.healthkit Code=5 "Authorization not determined"

I have determined authorization before actually trying to save any data or do anything with it. The error is happening at the moment of query: HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:foodType predicate:predicate…
Async-
  • 3,140
  • 4
  • 27
  • 49
1
vote
1 answer

Exclude own samples from healthkit queries

I'm writing an app that amongst other things, reads weight samples from HealthKit. I'm also writing samples. I'm trying to read the latest sample that isn't mine: NSPredicate* non_fdct = [NSCompoundPredicate notPredicateWithSubpredicate:[HKQuery…
Moshe Gottlieb
  • 3,963
  • 25
  • 41
1
vote
1 answer

Getting most recent BMI value from HKHealthStore

I want to get the users most recent BMI reading from my instance of HKHealthStore. As of right now I am doing it as follows but it doesn't seem right. Is there a way to get an actual numerical value for BMI instead of a countUnit…
Patrick
  • 302
  • 1
  • 3
  • 13
0
votes
1 answer

How to Query for HeartRates in HealthKit to get both traditional HKQuantitySamples as well as Cumulative Quantity Samples?

My heart rate query below uses the older traditional HKSampleQuery to get heart rates, however, if an app saves Heart Rates into Apple Health as a HKCumulativeQuantitySample then my query below doesn't capture all of the heart rates inside the…
GarySabo
  • 5,806
  • 5
  • 49
  • 124
0
votes
1 answer

iOS Swift, How to differentiate the steps using Apple Watch and iPhone?

I am using the HealthKit framework to retrieve the steps from the user using HKSource. In Xcode Objective C, I used Bundle Identifier to differentiate between steps from watch/iPhone. But using Swift I was not able to do so. Please suggest. Thanks…
0
votes
1 answer

Extra Characters when pulling from HealthKit

When I pull my HealthKit data using HKSampleQuery, I create an array and then populate a tableview. However, when I do this my tableViewCell has many other characters after the blood sugar number. Here's a screenshot of the cell: Heres where I…
Johnd
  • 584
  • 2
  • 6
  • 21
0
votes
1 answer

HKQueryOptions in predicate

I am trying to use a predicate to take the data from the last 30 days from HealthKit. Many of the tutorials online use .None as their HKQueryOption, and as I am unfamiliar with HKQueryOptions, I was wondering if anyone else knew what could replace…
Johnd
  • 584
  • 2
  • 6
  • 21
0
votes
1 answer

Why is my HKHealthStore.DeleteObjectAsync method not executing and returning an object in Xamarin?

I am trying to delete an HKObject added by my Xamarin.iOS app. I am able to successfully save and query the data from the Apple HealthKit, but the HKHealthStore.DeleteObjectAsync (and HKHealthStore.DeleteObject) method vanishes after it is run.…
mpt1555
  • 3
  • 2
0
votes
1 answer

After using HealthKit to retrieve SleepAnalysis, I still get this Authorization Not Determined error

I've been using references to this error for a few days now trying to figure out a solution: [query] Error activating query: Error Domain=com.apple.healthkit Code=5 "Authorization not determined" UserInfo={NSLocalizedDescription=Authorization not…