【发布时间】:2014-09-24 07:02:00
【问题描述】:
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if ([HKHealthStore isHealthDataAvailable]){
NSSet *writeDataTypes = [self dataTypesToWrite];
NSSet *readDataTypes = [self dataTypesToRead];
[self.healthStore requestAuthorizationToShareTypes:writeDataTypes readTypes:readDataTypes completion:^(BOOL success, NSError *error) {
NSLog(@"%s",__func__);
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);
return;
}
dispatch_async(dispatch_get_main_queue(), ^{
// Update the user interface based on the current user's health information.
NSLog(@"=========================== %s",__func__);
});
}];
}
}
requestAuthorizationToShareTypes 不回调完成方法。
【问题讨论】:
-
如果工作表从未出现并且从未调用完成,那么这听起来像是您应该提交的错误 (bugreporter.apple.com)。您是否尝试过查看设备的控制台输出以查看是否记录了任何错误?
-
是的,我在控制台上什么都没试过。
-
我遇到了同样的问题,所以我崩溃了:devforums.apple.com/thread/248835?tstart=0
-
我得到一个控制台错误:__NSCFConstantString _allowAuthorizationForSharingWithEntitlements: 并跟踪:HKObjectType(HKAuthorization) _allowAuthorizationForSharing:types:entitlements:disallowedTypes, _throwIfAuthorizationDisallowedForSharing:types 和 requestAuthorizationToShareTypes:readTypes:shouldPrompt:completion
-
@marciokoko 当您应该传递 HKObjectType 时,您正在将 NSString 传递给 API。
标签: request ios8 xcode6 healthkit