Skip to content

Instantly share code, notes, and snippets.

@mattrobmattrob
Created July 12, 2017 18:55
Show Gist options
  • Save mattrobmattrob/5c45b869738ecd352c40f02439a7d184 to your computer and use it in GitHub Desktop.
Save mattrobmattrob/5c45b869738ecd352c40f02439a7d184 to your computer and use it in GitHub Desktop.
Strava Apple Watch Blog - HealthKit
/// After using `requestAuthorizationToShareTypes:readTypes:completion:`
- (BOOL)hasRequestedHeartRateAuthorization
{
return (HKAuthorizationStatusNotDetermined != [HKHealthStore authorizationStatusForType:[HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeartRate]]);
}
- (void)requestHeartRateAuthorizationWithCompletion:(void (^)(BOOL succes, NSError *error))completion
{
NSSet *readTypes = [NSSet setWithObject:[HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeartRate]];
[self.store requestAuthorizationToShareTypes:nil readTypes:readTypes completion:^(BOOL success, NSError *error){
completion(success, error);
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment