我似乎无法捕获和处理取消 HealthKit 权限的用户。完成块总是返回成功和零错误。
[[DataManager healthStore] requestAuthorizationToShareTypes:dataTypesToWrite
readTypes:dataTypesToRead
completion:^(BOOL success, NSError *error)
{
if (!success)
{
NSLog(@"You didn't allow HealthKit to access these read/write data types. In your app, try to handle this error gracefully when a user decides not to provide access. The error was: %@. If you're using a simulator, try it on a device.", error);
}
if (completion)
{
completion(success,error);
}
}];