Search code examples
ioshealthkitios-extensions

Can I access healthkit data from iWatch extension?


I am making a iWatch app where I need to show data from healthkit. is it possible to access healthkit APIs from iWatch extension?


Solution

  • No. It's mentioned specifically in the HealthKit Framework Reference:

    "You cannot access HealthKit from extensions (like the Today view) or from a WatchKit app."

    What you can do is call openParentApplication:reply: to talk to the iPhone app itself and retrieve that data. Search around for that method name and you'll find some examples on how to call it and get data back to the Watch from it.


    UPDATE: As others have mentioned below, this has changed for watchOS 2. The documentation has not been updated yet, but check out the WWDC 2015 videos for HealthKit and the Watch for some snippets of code you can use with the Xcode 7 beta.