Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't get HealthKit to work. Missing Entitlement

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"];
    }

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?

like image 828
Marcelo Ribeiro Avatar asked Nov 27 '14 02:11

Marcelo Ribeiro


People also ask

Is Apple health the same as HealthKit?

In a nutshell, the Health app gathers information from your iPhone, Apple Watch and third-party apps to quantify data about you and your environment and display it in an easy-to-read, secure and accurate dashboard. HealthKit is the developer framework behind it that allows apps to work with Apple Health and each other.

How does Apple HealthKit work?

The Health app gathers health data from your iPhone, Apple Watch, and apps that you already use, so you can view all your progress in one convenient place. Health automatically counts your steps, walking, and running distances. And, if you have an Apple Watch, it automatically tracks your Activity data.

How do I disable HealthKit?

There's no way to de-authorize HealthKit access programmatically, but there's also no need to. When the switch is disabled you should just make sure to not query HealthKit anymore.


1 Answers

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.

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

like image 128
Andrew Ebling Avatar answered Nov 07 '22 05:11

Andrew Ebling