Update Heart Rate

I'm attempting to tell the Apple Watch to update the heart rate. Any ideas on how to force update? I'd like it to update every x amount of time.

Below is my query.


HKQuantityType *heartRateQuantityType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeartRate];
   
   
    NSSortDescriptor *timeSortDescriptor = [[NSSortDescriptor alloc] initWithKey:HKSampleSortIdentifierEndDate ascending:NO];
   
    HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:heartRateQuantityType predicate:nil limit:1 sortDescriptors:@[timeSortDescriptor] resultsHandler:^(HKSampleQuery *query, NSArray *results, NSError *error) {
        if (!results) {
            NSLog(@"An error occured fetching the user's tracked food. In your app, try to handle this gracefully. The error was: %@.", error);
           
            /
           
        }


All help is much appreciated, as the current docs don't seem to cover this.

Replies

There's no way to tell HealthKit to update the HR every x amount of time. The best thing you can do is to start a workout session (HKWorkoutSession) on the watch by calling startWorkoutSession. Once you do this you'll get HR updates every 5 seconds or so.