我无法让HealthKit正常工作.缺少权利 [英] I can't get HealthKit to work. Missing Entitlement

查看:201
本文介绍了我无法让HealthKit正常工作.缺少权利的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难让HealthKit在我的iOS应用程序上正常工作.我已经完成了所有步骤到目前为止我已经找到,而且似乎都无法解决我的问题是,尝试授权Healthkit时,我总是收到此错误:

I am having a hard time to get HealthKit working for my iOS App. I have done all the steps I have found so far and none seem to solve my problem I keep getting this error when trying to authorize Healthkit:

Error Domain=com.apple.healthkit Code=4 "Missing com.apple.developer.healthkit entitlement." UserInfo=0x78fa24e0 {NSLocalizedDescription=Missing com.apple.developer.healthkit entitlement.}

这是我的代码要求授权:

Here is my code asking for authorization:

    if([HKHealthStore isHealthDataAvailable]) {

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

        [self.healthStore requestAuthorizationToShareTypes:nil readTypes:[self dataTypesToRead] completion:^(BOOL success, NSError *error) {

            if (!success) {
                NSLog(@"HK Error: %@", error);
                [self presentHealthAlert:@"You didn't allow APP to access HealthKit Data. Please go to Settings and set up APP permissions." withTitle:@"Error"];
            } else {
                [self presentHealthAlert:@"Thank You For Access" withTitle:@"Success"];
            }
        }];

    } else {
        [self presentHealthAlert:@"Health Data Not Available" withTitle:@"Success"];
    }

是的,我已经在我的项目Capabilites上启用了它,是的,我在我的Dev Center应用程序ID中启用了它.还有其他我可能会想念的东西吗?

And Yes, I have enabled it on my project Capabilites, and yes I have enabled it in my Dev Center App ID. Is there anything else I might be missing?

推荐答案

我在watchOS 2应用中遇到了这个问题.解决方案是确保我同时为iOS应用手表扩展程序的 启用了HealthKit权利.

I had this problem with a watchOS 2 app. The resolution was to ensure I had enabled the HealthKit entitlement for both the iOS app and the watch extension.

我错误地认为手表扩展程序会继承iOS应用程序的开关.

I had wrongly assumed the switch for the iOS app would be inherited by the watch extension.

这篇关于我无法让HealthKit正常工作.缺少权利的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆