Skip to content

Instantly share code, notes, and snippets.

@scottmkroberts
Last active August 29, 2015 14:04
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 scottmkroberts/4054e0098570d980943b to your computer and use it in GitHub Desktop.
Save scottmkroberts/4054e0098570d980943b to your computer and use it in GitHub Desktop.
checkAuthorisationForCharacteristicType
-(BOOL)checkAuthorisationForCharacteristicType:(HKCharacteristicType *)characteristicType{
HKAuthorizationStatus authStatus = [self.store authorizationStatusForType:characteristicType];
if(authStatus == HKAuthorizationStatusSharingAuthorized){
return YES;
}else{
return NO;
}
}
//Check auth is avilable for HKCharacteristicType
HKCharacteristicType *dateOfBirthType = [HKCharacteristicType characteristicTypeForIdentifier:HKCharacteristicTypeIdentifierDateOfBirth];
if([self checkAuthorisationForCharacteristicType:dateOfBirthType]){
NSDate *dateOfBirth = [self.store dateOfBirthWithError:&error];
NSLog(@"Users date of birth = %@", dateOfBirth);
}else{
NSLog(@"Users date of birth not accessible");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment