requestAuthorizationToShareTypes 方法在 iOS 8 Xcode 6 中不显示权限提示

标签 request ios8 xcode6 healthkit

-(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 不会回调完成方法。

最佳答案

我也遇到了类似的问题,权限框没有出现,并且没有正确设置 HKHealthStore,所以提前为我解决了这个问题

self.healthStore = [[HKHealthStore alloc] init];

关于requestAuthorizationToShareTypes 方法在 iOS 8 Xcode 6 中不显示权限提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26010554/

相关文章:

ios - 如何让约束自动调整大小和重新定位横向键盘键

objective-c - 转换为现代 Objective-C 语法 - 单个文件?

javascript - 端点异步轮询

javascript - Node 请求如何处理 session

ios - 如何使用代码在 Swift iOS8 中模拟按钮按下

iOS 8 : Mapkit error throws an : Must call -[CLLocationManager requestWhenInUseAuthorization]

google-chrome - Chrome 中 "Request Sent"的长时间

javascript - 通过 Heroku Scheduler (Node.js) 运行的抓取请求有一半的时间会失败

ios - Xcode6 ImageView + Assets 目录。图片未显示

swift - 无法使用 Storyboard 在 Xcode 6 中连接导出集合