hkhealthstore

HealthStore enableBackgroundDelivery when screen is locked

只愿长相守 提交于 2019-12-30 01:32:35
问题 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 plist and I have accepted healthStore type step count. Everything is fine when the app is open and when the screen is not locked. But when the screen is locked I don't get any observations. For test purpose the frequency is set to immediate. My code

HealthKit : Issue with associated samples deletion of provided workout

吃可爱长大的小学妹 提交于 2019-12-11 06:36:24
问题 Using HealthKit, I am saving below data: Workout Active Energy Distance I am deleting workout using below code: self.healthStore?.delete(workout, withCompletion: { (status, error) in But above code just deletes a workout from HealthKit app. I want to delete workout and it's associated samples. How can i do this? 回答1: To delete associated samples we need to perform delete query on specific HKQuantityTypeIdentifier . To delete Active Energy from Workout refer below code: let

Understanding results from HKSourceQuery, or Sources in general

最后都变了- 提交于 2019-12-10 11:42:14
问题 I just did a HKSourceQuery and got some results. When I do a println of the results, I got this: <HKSource:0x156c1520 "Health" (com.apple.Health)>//description of the object How do I use this to make a predicate using the HKQuery.predicateForObjectsFromSource(/* source goes here */) 回答1: Here is the sample code in Obj-c, NSSortDescriptor *timeSortDesriptor = [[NSSortDescriptor alloc] initWithKey:HKSampleSortIdentifierEndDate ascending:NO]; HKQuantityType *quantityType = [HKQuantityType

Health handles multiple step sources differently than HealthKit—swift

家住魔仙堡 提交于 2019-12-10 04:34:19
问题 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, everything works fine and the step count shown by my app matches with the Health app's step count. However, when there are multiple sources of data—on my personal iPhone, my Pebble Time smartwatch and the iPhone's pedometer both feed steps to Health—my app

Understanding results from HKSourceQuery, or Sources in general

有些话、适合烂在心里 提交于 2019-12-06 15:58:32
I just did a HKSourceQuery and got some results. When I do a println of the results, I got this: <HKSource:0x156c1520 "Health" (com.apple.Health)>//description of the object How do I use this to make a predicate using the HKQuery.predicateForObjectsFromSource(/* source goes here */) Here is the sample code in Obj-c, NSSortDescriptor *timeSortDesriptor = [[NSSortDescriptor alloc] initWithKey:HKSampleSortIdentifierEndDate ascending:NO]; HKQuantityType *quantityType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierActiveEnergyBurned]; HKSourceQuery *sourceQuery = [

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

折月煮酒 提交于 2019-12-04 23:46:48
问题 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 for adding and deleting objects. Whenever I start the app I am calling the HKQuery for the newest objects and executingQuery which works fine!!! But I am getting no new samples even if the samples are there, but if I bring the app to the background

Heart Rate With Apple's Healthkit

依然范特西╮ 提交于 2019-12-02 02:46:46
问题 I'm currently using Healthkit in an app and have no problems getting info for most types, but am having trouble with the Heart Rate. Every time I try to read a sample, I get "0" as a result. I have an Apple Watch, and my Heart Rate gets fed into the Apple Health app, and can visually see it there, so it's not a hardware issue. I only need to display it, no need to write the data back. It asks my permission on first run to allow access to the heart rate, so shouldn't be any issues with that

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

a 夏天 提交于 2019-12-01 10:42:34
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 metadata. But the value for 'HKMetadataKeyTimeZone' key is always nil even for the health data that is automatically recorded by Apple's Health app. Same problem for the data that is manually entered on Apple's Health app. So is there any other key/way that can give the time zone information for each sample? or Apple's health app is not at all logging

HealthKit data inaccessible in background

試著忘記壹切 提交于 2019-12-01 03:42:13
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 is inaccessible} . Apple states: Because the HealthKit store is encrypted, your app cannot read data from the store when the phone is locked. This means your app may not be able to access the store when it is launched in the background. Any workaround to access data in the background? Is the HKObserverQuery the only way to get data in the background

HealthKit data inaccessible in background

。_饼干妹妹 提交于 2019-12-01 01:07:03
问题 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 is inaccessible} . Apple states: Because the HealthKit store is encrypted, your app cannot read data from the store when the phone is locked. This means your app may not be able to access the store when it is launched in the background. Any