Questions tagged [hkhealthstore]

The HealthKit store acts as your link to all the data managed by HealthKit. Availability : Available in iOS 8.0 and later

Use a HealthKit store to request permission to share or read HealthKit data. Once permission is granted, you can use the HealthKit store to save new samples to the store, or to manage the samples that your app has saved. Additionally, you can use the HealthKit store to start, stop, and manage queries.

Quick Reference :

106 questions
15
votes
2 answers

HealthKit (iOS) won't deliver data in background (objC)

We're currently trying to get HealthKit to work in the background, in order to deliver steps data to our server when the App is closed. For experimental purposes we've created a brand new iOS project in XCode, enabled HealhtKit and all background…
Oakleaf
  • 393
  • 3
  • 14
13
votes
1 answer

REST API for Apple Health Data

Is there any REST API support for health data by Apple? I know healthkit api helps to send and receive data from apple health data store but it is very much restricted to ios apps. What i am trying to achieve is to utilize the send/receive from any…
11
votes
1 answer

HealthKit data inaccessible in background

I want to pull HealthStore data in the background using background fetch but I keep getting an error: Error Domain=com.apple.healthkit Code=6 "Protected health data is inaccessible" UserInfo=0x17026fdc0 {NSLocalizedDescription=Protected health data…
efremidze
  • 2,640
  • 1
  • 25
  • 35
10
votes
5 answers

How to read heart rate from iOS HealthKit app using Swift?

I'm using the following Swift code. let sampleType : HKSampleType = HKSampleType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeartRate) let nowDate: NSDate = NSDate() var calendar: NSCalendar = NSCalendar.autoupdatingCurrentCalendar() let…
Senthilkumar
  • 2,471
  • 4
  • 30
  • 50
9
votes
1 answer

Health handles multiple step sources differently than HealthKit—swift

My Swift iOS app connects with HealthKit to show the user how many steps they have taken so far in the day. For the most part, this is successful. When the sole source of steps is steps recorded by the iPhone's built-in pedometer function,…
owlswipe
  • 19,159
  • 9
  • 37
  • 82
6
votes
1 answer

HKMetadataKeyTimeZone is always nil for health data which is created by apple's Health App - HealthKit - iOS

I'm reading user's health data using HealthKit. Trying to get the timezone information from Health data to identify on which exact timezone the health activity has happened. For this, I'm depending on 'HKMetadataKeyTimeZone' key from HealthKit…
Ashok
  • 5,585
  • 5
  • 52
  • 80
6
votes
4 answers

HealthStore enableBackgroundDelivery when screen is locked

Hello I'm trying to setup the health store observer with background delivery enabled. My problem is that it won't deliver anything when the screen is locked. I have simplified my code for this question to get to the point :) I have HealthKit in my…
5
votes
1 answer

HKSampleQuery returns no results even when there are

I'm trying to get all heart rate samples from the past month, and extract the times and values from them. So far, I've got the following method: func getThisMonthsHeartRates() { print("func called") let heartRateUnit:HKUnit = HKUnit(from:…
bdv
  • 1,154
  • 2
  • 19
  • 42
5
votes
2 answers

How to detect if the user doesn't allow Apple Health Kit Authorisation?

I am using AppleHealthKit in my application. Everything is working correctly. The problem is that I am not able to detect if the user taps "Don't Allow" button when asking for permission. With this method, my application uses HealthKit, even though…
Byte
  • 629
  • 2
  • 11
  • 29
5
votes
2 answers

Monitor heart rate from HealthKit --> HKAnchoredObjectQuery only called after applicationDidBecomeActive (BUG or FEATURE?)

I am writing a simple app to monitor the heart rate (HKQuantityTypeIdentifierHeartRate) from HealthKit whenever a new health rate value is written to HealthKit. As seen at WWDC2015 (session 203) I am using a HKAnchoredObjectQuery which should work…
Ing. Ron
  • 2,005
  • 2
  • 17
  • 33
5
votes
1 answer

How to update iOS app with Apple Watch heart rate via healthkit? (HealthKit sync)

My watch app is easily capable of reading new heart rate data from HealthKit's new updateHandler in HKAnchoredObjectQuery. Trouble is, the health store that the phone app observes seems to be unsynchronized with the watch. Suspending the app and…
TealShift
  • 842
  • 5
  • 19
4
votes
2 answers

How to get steps count on hourly basis from HealthKit Swift 4

I need to plot graph for steps taken by user on hourly basis on any specific date. But if the user's steps start today at 3:58 pm and end today at 4:10 pm then I am getting just one HKStatistics object for this period of time. I am not able to break…
Rohan Mali
  • 61
  • 1
  • 7
4
votes
0 answers

Watch app starts with big delay after calling HKHealthStore method startWatchApp(with:completion:)

I'm working on workout iOS app with counterpart watchOS app, and I have issue with starting watch app from iOS using HKHealthStore method startWatchApp(with:completion:). Sometimes after calling startWatchApp method the watch app starts with huge…
4
votes
3 answers

Getting all steps of today but truncating manually added steps, from Health kit using swift

I am getting today steps from healthkit using below code. func retrieveStepCount(completion: (stepRetrieved: Double) -> Void) { let type = HKSampleType.quantityTypeForIdentifier(HKQuantityTypeIdentifierStepCount) let date =…
Byte
  • 629
  • 2
  • 11
  • 29
4
votes
1 answer

HealthKit Workout Queries seem really slow

I have some code which is querying data from healthkit. We get various samples and quantities from the healthkit as well as recent workouts. On my phone (usually a workout every day - although the Basis stores things as multiple workouts), the…
Fiid
  • 1,852
  • 11
  • 22
1
2 3 4 5 6 7 8