Skip to content

Reference

Exported functions

deviceIdentifier()

Returns the native TrainingKit device identifier as a string.

ts
function deviceIdentifier(): string

This call is synchronous on both iOS and Android. The identifier is stable for a given device installation.

Use it as the value of the X-TrainingKit-Device HTTP header on every GraphQL request.


launchWorkout(session)

Launches the native workout experience from a TrainingKit session payload.

ts
function launchWorkout(session: TrainingKitSession): void

The function inspects session.__typename and session.format to determine which native flow to launch:

ConditionNative flow
__typename === 'WorkoutBlockSession' or format === 'CLASSIC'Classic workout
__typename === 'WorkoutVideoSession' or format === 'PLAY'Video workout

Throws if trainingKitToken is missing or if the session type cannot be identified.

Types

TrainingKitSession

ts
type TrainingKitSession = {
  __typename?: string
  format?: string
  trainingKitToken: string
  [key: string]: unknown
}

The minimum shape required by launchWorkout. The full GraphQL session payload (which may contain many additional fields) satisfies this type and is passed through to the native SDK as a JSON string.

Native module

The package registers a single native module named TrainingKitModule. It is loaded automatically on both platforms via React Native autolinking.

The three underlying native methods are not intended to be called directly:

MethodDescription
deviceIdentifier()Returns the native device ID
launchClassicWorkout(jsonString, token)Launches the classic workout controller
launchVideoWorkout(jsonString, token)Launches the video workout controller

Use deviceIdentifier() and launchWorkout() from the package instead.

Error messages

MessageCause
TrainingKitModule is not available. Make sure trainingkit-reactnative is linked and the native app was rebuilt.The native module was not found. The app needs a native rebuild after installing the package.
TrainingKit session is missing trainingKitToken.The session object passed to launchWorkout does not contain trainingKitToken. Check that the full session payload was fetched before calling launchWorkout.
Unsupported TrainingKit session type: <type>.The __typename and format fields do not match any known workout kind. Verify the GraphQL response.