Skip to content

Instantly share code, notes, and snippets.

@max6363
Created May 8, 2018 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save max6363/21187f8157e68ccc1e2b53cb6fcb8498 to your computer and use it in GitHub Desktop.
Save max6363/21187f8157e68ccc1e2b53cb6fcb8498 to your computer and use it in GitHub Desktop.
/**
Request to read data from health application.
*/
- (void)requestToReadDataWithFinishBlock:(void (^)(NSError *error))finishBlock
{
// read permission
NSArray *readTypes = @[
[HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceCycling]
];
[self.healthStore requestAuthorizationToShareTypes:nil
readTypes:[NSSet setWithArray:readTypes]
completion:^(BOOL success, NSError * _Nullable error) {
dispatch_sync(dispatch_get_main_queue(), ^{
if (error) {
finishBlock(error);
} else {
finishBlock(nil);
}
});
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment