Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
[ad_1]
I wish to write knowledge to AppleHealth from my health app. So I create an HKWorkout pattern, and add exercise occasions there (e.g. Squat, Assisted dip, Barbell Curl).
Right here is the way in which I create HKWorkoutEvent array
var workoutEvents = [HKWorkoutEvent]()
var metadata: [String: Any] = [:]
workoutEvents = exercise.workoutExercises.map {
metadata[HKMetadataKeyWorkoutBrandName] = $0.train.title
return HKWorkoutEvent(
sort: .phase,
dateInterval: DateInterval(begin: $0.timeStartedDate, length: 60.0 * 6),
metadata: metadata
)
}
And right here is the way in which I create single HKWorkout occasion
let hkworkout = HKWorkout(
activityType: .traditionalStrengthTraining,
begin: startDate,
finish: endDateUsing,
workoutEvents: workoutEvents,
totalEnergyBurned: caloriesBurnt,
totalDistance: nil,
totalSwimmingStrokeCount: nil,
machine: .native(),
metadata: nil)
After which I save that exercise like this
HKHealthStore().save([hkworkout]) { success, error in }
My downside is after I head to Apple Well being app, and browse information from my app, there aren’t any train names displayed. As an alternative I see solely “Section” phrase associated to every exercise, which may be very irritating for the person I suppose, as he would most likely wish to see which exercise he frolicked on, and many others.
See screenshot hooked up under
So I suppose HKWorkoutEvent doesn’t learn knowledge from HKMetadataKeyWorkoutBrandName
worth and units “phase” phrase for all of the exercise occasions.
Is there any approach to have precise exercise occasion title displayed in Apple Well being?
[ad_2]