I can't get HealthKit to work. Lack of access rights

It’s hard for me to get HealthKit for my iOS app. I took all the steps I found so far and no one seems to be solving 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 requiring 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 included it in my Capabilites project, and yes, I included it in my Dev Center app ID. Is there anything else I can lose?

+5
source share
7 answers

I had this problem with watchOS 2. The resolution was to enable HealthKit on both the iOS app and the chat extension.

I mistakenly assumed that the switch for the iOS application would be inherited by the clock extension.

+5
source

You need to make sure that you click on your program to the left of Xcode (at the top of the file hierarchy). You will go to the general settings screen in the main window (on the right), where you will see the package identifier, deployment target and additional settings. Click on the tab at the top that talks about the features. You will now see a list that includes HealthKit. You must activate it here before you can use it in the application.

Edit: here is an image from Xcode that can help you find this if you are not familiar with dependency settings or other program settings.

Screenshot showing where the list with HealthKit is

In this list on the right, below you will see HealthKit. It will check a few things as soon as you turn it on and make sure you can use it.

+1
source

A bit out of date, but for everyone who has problems, I had to manually update the preparation profiles, as well as in XCode 6.2 (Preferences β†’ Accounts).

+1
source

I ended up here, reaching my wit. Nothing worked, and I clearly got the right to HealthKit, so finally I just restarted the phone. Voila. Restarting resolves missing rights errors.

+1
source

I managed to get my right to work, making sure that my device is registered. As soon as I got my iPhone, showing under the simulator, and I did not have any unresolved problems in the application identification section, it all loaded fine.

0
source

You may find that although you have included the HealthKit right in xcode, there is a second rights file that does not contain the logical name healthkit. I found that although the file with the obvious rights (at the top level) contains the correct information, in the Resources section, another rights file was created that does not contain the right to health. fixing this file fixed my problem.

0
source
  • Click Watch Application Extension .

  • Click on Features .

  • Scroll down the page and enable HealthKit .

enter image description here

0
source

Source: https://habr.com/ru/post/1207775/


All Articles