Skip to content

Delegates ​

This page documents callback contracts between TrainingKit and host app code.

DocC symbol source is available at:

https://github.com/getfizzup/trainingkit-ios-sdk/blob/main/documentation/TrainingKit.doccarchive.zip

TrainingKitInterface ​

TrainingKitInterface is the core host lifecycle protocol implemented by TrainingKit controllers.

MethodContract
saveSession(state: SaveWorkoutState)Persist session results in host backend/app logic. Call super in controller overrides.
displayPostWorkout() -> AnyPublisher<Void, Never>Return publisher that completes when post-workout flow is done.
quitWorkout()Handle quit-without-save flow. Call super and ensure handling of non-UI-thread invocations.

ClassicWorkoutController and StreamingWorkoutController both provide default implementations for this protocol.

TrainingKitLogInterface ​

TrainingKitLogInterface provides host-level logging and tracking hooks.

MethodContract
log(_ message: String, context: [String: AnyHashable]?)Receives debug log messages and optional metadata context.
trackEvent(_ name: Tracking.Event, properties: [Tracking.Property: String]?)Receives structured analytics events emitted by TrainingKit.

TrainingKitRegularInterface ​

This protocol covers business callbacks specific to regular workouts.

MethodContract
getAllRecommendations(contentIdentifier: String?) -> AnyPublisher<Data, Never>Called by the middleware to asynchronously fetch every recommendation associated with the workout currently being performed.
buyPremiumContent(from: UIViewController?, placement: String?, contentIdentifier: String?) -> AnyPublisher<BoughtContent, Never>Called when the user taps the subscribe button from a premium section preview. The host app presents any required purchase UI and returns the unlocked workout data.
buyPremiumRecommendation(from: UIViewController?, placement: String?, contentIdentifier: String?) -> AnyPublisher<BoughtContent, Never>Called when the user taps the subscribe button from a premium section preview for an optional recommendation. Returns the unlocked recommendation data.

RemoteManagerDelegate ​

RemoteManagerDelegate defines all requirements used by a remote media client to communicate with the workout controller.

MethodContract
remoteSessionDidStart()Called when the device did complete session creation and connection to the receiver.
remoteSessionDidEnd(at: CMTime)Called when the device did stop session and quit connection to the receiver.
remoteSessionDidResume()Called when the device gets connected back to the receiver.
remoteSessionCanStartMedia()Called when no media is playing on the receiver.
remoteSessionCanResumeMedia(at: CMTime)Called when the same media is playing on the receiver.
remoteSessionOtherMediaPlaying()Called when another media is playing on the receiver.
remoteSessionDidUpdateMediaStatus(time: CMTime, hasMedia: Bool, state: RemoteMediaPlayerState?)Called when a media status update occurred.
remoteSessionDidUpdateMetadata(coverUrl: URL?)Called when a metadata update occurred.
remoteDidTapQuitWorkout()Called when the user taps quit workout from the remote client.