I’m at the moment creating a health app for watchOS that lets a person to manually set a desired coronary heart price goal zone (enter numbers representing the decrease and higher boundaries) and begin a exercise (proper now it’s solely “Different” kind). After that my app screens person’s coronary heart price and alerts them after they’re out of zone.
When person ends the exercise, the data about this exercise seems on “Health” iOS app, and person can see the exercise information like Exercise Time, Energetic and Complete Energy, Avg. Coronary heart Fee. Additionally person can see Coronary heart Fee chart with data how their coronary heart price was altering throughout a exercise (see the Determine 1).
Now to the query.
When person clicks “Present Extra” button above the Coronary heart Fee chart, they’ll see the identical Coronary heart Fee chart and one other one, with Put up-Exercise Coronary heart Fee (see the Determine 2).
However there is no such thing as a “Estimated time in every coronary heart price zone” as one can see within the exercise’s particulars that have been recorded from Apple’s exercise (watchOS “Exercise” app, for a exercise of “Different” kind as nicely), please see the Determine 3.
The query is: is it attainable so as to add “Estimated time in every coronary heart price zone” to exercise recorded through my third-party app so it might appear like on the Determine 3 in “Health” iOS app, and if it is attainable, what steps ought to I undertake to implement this?
How I arrange the HKHealthStore to make use of it for and HKWorkoutConfiguration, HKWorkoutSession, HKLiveWorkoutBuilder:
var hkObject: HKHealthStore?
let workoutConfig = HKWorkoutConfiguration()
var workoutSession: HKWorkoutSession? = nil
var workoutBuilder: HKLiveWorkoutBuilder? = nil
init() {
hkObject = HKHealthStore()
hkObject?.requestAuthorization(toShare: [HKQuantityType.workoutType()], learn: [HKQuantityType(.heartRate), HKQuantityType(.activeEnergyBurned), HKQuantityType(.basalEnergyBurned)]) {(success, error) in
if success {
print("Authorization succeeded")
} else {
print("Authorization failed")
}
}
workoutConfig.activityType = .different
do {
workoutSession = strive HKWorkoutSession(healthStore: hkObject!, configuration: workoutConfig)
workoutBuilder = workoutSession?.associatedWorkoutBuilder()
workoutBuilder?.dataSource = HKLiveWorkoutDataSource(healthStore: hkObject!, workoutConfiguration: workoutConfig)
print("Exercise session and builder have been created efficiently")
} catch let error {
......
}
}
What I can see in Health app now (Figures 1-2) and what I wish to see (Determine 3)
Determine 1, common data concerning the exercise from my app in “Health” app
Determine 2, detailed data about Coronary heart Fee throughout the exercise from my app in “Health” app
Determine 3, what I wish to have: detailed data about Coronary heart Fee with coronary heart price zones throughout the exercise recorded by watchOS “Exercise” app in “Health” app
Thanks prematurely!