healthkit

HealthKit cannot read steps data

妖精的绣舞 提交于 2019-12-11 13:07:22
问题 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 *stepsType =[NSSet setWithObject:[HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount]]; [self.healthStore requestAuthorizationToShareTypes:nil readTypes:stepsType completion:^(BOOL success, NSError * _Nullable error) { if (success) { HKSampleType *sampleType

Does HKObserverQuery can receive notification when the application not running(Killed)?

混江龙づ霸主 提交于 2019-12-11 08:34:43
问题 My requirement is to register for any one of the Health data like steps, weight, heart rate, etc., for background delivery using enableBackgroundDeliveryForType: method. And then create a Observer query for the same Health data to check. In this scenario, if my application is killed by the user forcely and did changes to Health data using Health app. By this stage is it possible to get the notification to My application? Is it mandatory to register for any of the background modes, to get

iOS on device Unit Testing fails to start - HealthKit entitlements error

牧云@^-^@ 提交于 2019-12-11 06:37:18
问题 Whenever I try to run the unit tests on device. Everything seems to build and install onto the device but I get the following error in a dialog when it is about to run: The executable was signed with invalid entitlements. The entitlements specified in your application’s Code Signing Entitlements file are invalid, not permitted, or do not match those specified in your provisioning profile. (0xE8008016). Unit testing on simulator works fine. However I would like to get unit tests to work on the

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

HealthKit crashing when pulling heart rate on second call after working on first call even when not running any code

筅森魡賤 提交于 2019-12-11 05:57:00
问题 I have a WatchKit app using HealthKit. When a view (with custom WKInterfaceController MonitorMetrics) appears it runs the following code: func startRecordingHeartRate() { let heartRateSample = HKSampleType.quantityType(forIdentifier: HKQuantityTypeIdentifier.heartRate) let heartRateUnit = HKUnit.count().unitDivided(by: HKUnit.minute()) let datePredicate = HKQuery.predicateForSamples(withStart: Date(), end: nil, options: .strictStartDate) let anchor: HKQueryAnchor? = nil let updateHandler:

Can I access healthkit data from iWatch extension?

假如想象 提交于 2019-12-11 04:49:12
问题 I am making a iWatch app where I need to show data from healthkit. is it possible to access healthkit APIs from iWatch extension? 回答1: No. It's mentioned specifically in the HealthKit Framework Reference: "You cannot access HealthKit from extensions (like the Today view) or from a WatchKit app." What you can do is call openParentApplication:reply: to talk to the iPhone app itself and retrieve that data. Search around for that method name and you'll find some examples on how to call it and get

What's the logic in HKObserverQuery background delivery?

拈花ヽ惹草 提交于 2019-12-11 01:42:08
问题 I need my app to sync between HealthKit and our database while it's in the background. I just can't wrap my head around the logic that determines how and when the HKObserverQueries run their updateHandlers. I need data of various different sample types, so I assume I need an observer query for each one. Right? According to Apple about function enableBackgroundDeliveryForType, " HealthKit wakes your app whenever new samples of the specified type are saved to the store ." But if I enable