Skip to content

Instantly share code, notes, and snippets.

@max6363
Last active May 8, 2018 18:51
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/09533154aea5a41c94b66ad7b88d1f70 to your computer and use it in GitHub Desktop.
Save max6363/09533154aea5a41c94b66ad7b88d1f70 to your computer and use it in GitHub Desktop.
- (void)requestToWriteDataWithFinishBlock:(void (^)(NSError *error))finishBlock
{
// write permission
NSArray *writeTypes = @[
[HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount]
];
[self.healthStore requestAuthorizationToShareTypes:[NSSet setWithArray:writeTypes]
readTypes:nil
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