iosiphoneapple-watchwatchos-3

Read Heart Rate in Apple Watch Series 3 without creating an app on the Watch


Is it possible to read/sync the Heart Rate data from Apple watch series 3 without creating a watch app? I want my iPhone app to read data directly from the Apple Watch without having to create an app for the watch too.


Solution

  • Apple Watch syncs all of its recorded heart rate data (automatically sampled every five minutes while wearing, and more frequently during workout sessions) to the HealthKit store on the companion iPhone.

    So you can create an iOS app that (with the user's permission) reads the stored heart rate data using HealthKit. The gist of it:

    1. Set up your project for HealthKit support in Xcode's Capabilities pane (part of your app target settings).

    2. Check for HealthKit availability on the device (HKHealthStore.isHealthDataAvailable()) and create an HKHealthStore object.

    3. Verify that you have user permission to access heart rate data:

      let heartRateType = HKObjectType.quantityType(forIdentifier: .heartRate)!
      healthStore.requestAuthorization(toShare: nil, read: [heartRateType], completion: myHandler)
      
    4. After that completion handler reports success, use HKSampleQuery to search for the most recent heart rate sample, a set of heart rate samples within a specified time frame, etc. (Or other HKQuery subclasses for things like average heart rate over time, etc.)


    If instead what you're asking is for a way to read the user's current heart rate "right now" from an iOS app, without creating a companion watchOS app... no, there's not a way to do that.