HealthKit authorization in independent watchOS apps.

Hi,


I'm try to get HealthKit authorization in my independent watchOS 6 application. But for some reason executing the following code doesn't do anything. The given closure isn't triggered.


store.requestAuthorization(toShare: self.shareTypes, read: self.readTypes) { [weak self] _, error in
     
}


I added the two required entries to my Info.plist of the watchOS target, and the extension has the correct HealthKit entitlements. Is this feature not yet implemented in the current beta's?


Would love to start playing with this.

Accepted Reply

On Beta 5 it finally works on both device and simulator 🎉

Replies

I'm having the same problem in the simulator.

Would love to know if it's something that is not implemented yet or if my code is wrong.

I tested with the new Xcode 11 Beta 2 and the problem seems to persist.

I tested again and the issue is still happening on the simulator.

On my Apple Watch it's working fine though.

I'm seeing this too. Filing feedback

Same here. Came to see if I was the only one stuck with this.


Does anyone know if this works on a device running the beta?

Same behavior on the simulator Xcode 11 Beta 2, worked on the iWatch twice then got stuck.

Turns out that if you leave the simulator on for a long time you get an error message


requestAuthorizationCompletion error: Authorization session timed out

Today I also tried to create a non indipendent iOS13/WatchOS6 app


But still nothing seems to work.


I call


healthStore.requestAuthorization(...)

But nothing happen. I also implemented the


    func applicationShouldRequestHealthAuthorization(_ application: UIApplication) {
        healthStore.handleAuthorizationForExtension() { (succeded, optionalError) in
            if (succeded) {
                print("Succeded")
            } else if let error = optionalError {
                print("Error: \(error.localizedDescription)")
            } else {
                print("Error")
            }
        }
    }


in the host app.


The same code in iOS12/WatchOS5 works showing the expected HealthKit permission dialog

The issue still persists with Xcode 11 Beta 3. I also got the timeout error...


Sad panda...

I reported this as feedback FB6270775

Same for me. The code that works on iOS12/WatchOS5 Simulator doesn't work on iOS13/WatchOS6 Beta 3

For what is worth, my Feedback FB6270775 "Recent Similar Reports:Less than 10"


I guess it would help if more people with the same issue could fill a feedback report.

Cheers

Still happening in Beta 4


😢

It looks like it is working on the device. Finally. But the simulator is still failing...

On Beta 5 it finally works on both device and simulator 🎉