health-kit

Missing HealthKit Entitlement

梦想与她 提交于 2019-12-04 13:41:45
I am trying to integrate HealthKit with an app I'm building, and I seem to have successfully added the entitlement for it. I've created and downloaded a provisioning profile with the appropriate app ID, and the HealthKit toggle in the Xcode Capabilities tab seems to look fine: However, when I run the app, I get the following error: HealthKit authorization denied! Error Domain=com.apple.healthkit Code=4 "Missing com.apple.developer.healthkit entitlement." UserInfo={NSLocalizedDescription=Missing com.apple.developer.healthkit entitlement.} This is a strange error message to be getting since Add

Detect if HealthKit activity has been entered manually

穿精又带淫゛_ 提交于 2019-12-04 10:12:57
You can check which app inserted the activity via the 'source' activity. Is there a way to know if the activity has been entered manually or if the activity was an activity that was recorded live from sensors and added to HealthKit? Gurtej Singh Apple only provides two properties for the HKSource class, the bundleIdentifier and the name of the source, as of iOS8.x The bundle identifier of the entry if made manually will be com.apple.Health , which is the bundle identifier of the Health app. Notice the capital H . When you pull your data just ignore the data which has a bundle identifier of com

Why doesn't HKAnchoredObjectQuery with enableBackgroundDeliveryForType always fire when app is in the background?

情到浓时终转凉″ 提交于 2019-12-03 20:42:37
I'm experimenting a bit to familiarize myself with the HKAnchoredObjectQuery and getting results when my app is inactive. I start the app, switch away to Apple Health, enter a blood glucose result; sometimes the results handler is called right away (as evidenced by the print to the console) but other times the handler isn't called until I switch back to my app. Same is true for deleted results as well as added results. Anybody have any guidance? Most of this code is from a question from thedigitalsean adapted here to get updates while app is in the background and logging to the console. See:

How to get sensor data from Apple Watch to iPhone?

强颜欢笑 提交于 2019-12-03 13:01:00
Is there a way to get sensor data from Apple Watch? For example, how can I connect and get heart rate from Apple Watch to my app? These are the steps I need do in my app: Define a delegate to receive heart rate information from Apple Watch. Make a request to Apple Watch to send the data periodically I know how it works for other HR monitors over BT. Is the interface similar to that? Or should depend on HealthKit to achieve that? Greencat As per WatchKit FAQ on raywenderlich.com (scroll to "Can you access the heartbeat sensor and other sensors on the watch from your watch app?") it appears as

iOS HealthKit how to save Heart Rate (bpm) values? Swift

前提是你 提交于 2019-12-03 12:17:37
How to use : HKUnit Sample type Unit type Unit name Unit string Heart Rate count/time Beats per Minute "count/min” Swift : Heart Rate (bpm) save into healthkit store private func saveHeartRateIntoHealthStore(height:Double) -> Void { // Save the user's heart rate into HealthKit. let heartRateUnit: HKUnit = HKUnit.countUnit().unitDividedByUnit(HKUnit.minuteUnit()) let heartRateQuantity: HKQuantity = HKQuantity(unit: heartRateUnit, doubleValue: height) var heartRate : HKQuantityType = HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeartRate) let nowDate: NSDate = NSDate() let

HealthKit HKAuthorizationStatus for reading data

删除回忆录丶 提交于 2019-12-03 10:19:48
I'm using HealthKit to read certain types of information. I'm specifically not asking for write functionality. The problem comes in when trying to detect if the user has allowed a certain Health type to be read. I believe the intended way to do this is using an HKHealthStore's authorizationStatusForType method, but this is only returned denied or unknown. It is only returning authorized for write types. Has anyone found a way to use this method for reading or another work around? HKQuantityType *stepsType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeight];

HKWorkoutSession isn't keeping app at front of Apple Watch

人走茶凉 提交于 2019-12-03 10:05:02
问题 It has been stated that an app running a HKWorkoutSession will have special privileges over other watchOS 2 apps, so when a user looks at their Apple Watch, it will go to the view showing running a workout rather than the watch face. Currently, on both my device and simulator, this is not the case. If I start a HKWorkoutSession and then leave for 5 minutes and then interact with either the Apple Watch, or the Watch Simulator, it presents the watch face. If I then open my app, it appears to

HKWorkoutSession isn't keeping app at front of Apple Watch

ⅰ亾dé卋堺 提交于 2019-12-03 00:32:18
It has been stated that an app running a HKWorkoutSession will have special privileges over other watchOS 2 apps, so when a user looks at their Apple Watch, it will go to the view showing running a workout rather than the watch face. Currently, on both my device and simulator, this is not the case. If I start a HKWorkoutSession and then leave for 5 minutes and then interact with either the Apple Watch, or the Watch Simulator, it presents the watch face. If I then open my app, it appears to have been frozen, rather than terminated (which is what I imagine happens to other apps). As the UI will

iOS : Use of HKObserverQuery's background update completionHandler

孤者浪人 提交于 2019-12-02 21:34:21
HKObserverQuery has the following method that supports receiving updates in the background: - initWithSampleType:predicate:updateHandler: The updateHandler has a completionHandler which has the following documentation : This block is passed to the update handler. You must call this block as soon as you are done processing the incoming data. Calling this block tells HealthKit that you have successfully received the background data. If you do not call this block, HealthKit continues to attempt to launch your app using a backoff algorithm. If your app fails to respond three times, HealthKit

HKAnchoredQuery update handler not working properly

那年仲夏 提交于 2019-12-02 17:41:40
问题 I wrote a code to get heart rate values from Health kit. The code is working fine but when the new heart values are updated in Health kit. I have to come to main screen and then multitask my app to get the updated results. What my aim is to get the updated result on my app without reopening or multitasking it, please help as I am new to iOS development. My code:- -(void)get_heartRates { //code to get the updated heart beats HKSampleType *sampleType = [HKObjectType quantityTypeForIdentifier