Iñaki Gomez
Iñaki Gomez

Reputation: 1

Adding segments/splits into workout Swift

I am building a workout app that has an option to add segments to differentiate the stages of the training session. However, the segments are not visible in Fitness app.

Segments are added the following way:

func saveSegment(eventType: HKWorkoutEventType, startDate: Date, endDate: Date, inSeg: Int) async throws {
let dateInterval = DateInterval(start: startDate, end: endDate)
let event = HKWorkoutEvent(type: eventType, dateInterval: dateInterval, metadata: metadata)
try await builder?.addWorkoutEvents([event])
}

Inside Health -> Workouts -> Show All Data, the segments appear, but in Fitness app there are no segments. The workout is .paddleSports. I thought that maybe the workout type was the problem, but when I start the sessions from the native workout app, segments are added and shown in the Fitness app:

Segment example picture

In another post I saw suggested to add an event as .marker instead of .segment, but the result is the same, it does not appear. Is there something I am doing wrong? How can I show the segments into the Fitness app?

Thank you in advance.

Upvotes: 0

Views: 20

Answers (0)

Related Questions