Workouts and Activity Rings

Manage workouts, workout sessions, and activity summaries.

Overview

This section covers a number of topics related to physical activity, exercise and fitness.

A workout is a sample that contains data about an exercise or fitness activity. You save workout data using the HKWorkout class. In many ways, workouts are identical to any other HealthKit sample—the same advice and APIs apply to both workouts and samples. However, workouts do have a number of unique features, described in About Workout Samples.

Workout sessions let you track the user’s activity on Apple watch. While a workout session is active, your app can continue to run in the background. This lets your app montior the user and gather data throughout the activity. Additionally, it ensures that your app appears whenever the user checks their watch. After the session ends, your app saves the activity’s data as a workout sample. For more information on setting up and running workout sessions, see HKWorkoutSession.

The Activity Rings display a summary of the user’s daily activity on Apple watch and in the Activity app. Activity summaries provide access to the data displayed in the user’s Move, Exercise, and Stand rings. To see how your workout samples contribute to these rings, see Filling the Rings. To learn more about accessing and displaying activity data in your app, see Activity Rings.

Finally, workout routes record the user’s path during an outdoor activity (for example, while walking, running, or cycling). Routes can be associated with a workout sample. For more information, see Creating a Workout Route and Reading Route Data.

Topics

Samples

Using Workout Samples

Record a physical activity using workout samples.

HKWorkout

A workout sample stores information about a single physical activity.

HKWorkoutType

The workout type identifies samples that store information about a workout.

HKWorkoutTypeIdentifier

The workout type identifier.

HKWorkoutActivityType

The type of activity performed during a workout.

HKWorkoutEvent

An object representing an important event during a workout.

Sessions

Running Workout Sessions

Track the user’s activities on Apple Watch.

HKWorkoutSession

A workout session that tracks the user’s workout on Apple Watch.

HKWorkoutSessionDelegate

The session delegate protocol defines an interface for receiving notifications about errors and changes in the workout session’s state.

HKWorkoutSessionState

A workout session’s state.

HKWorkoutConfiguration

An object that contains configuration information about a workout session.

Workout Bulder

HKWorkoutBuilder

A builder object that constructs a workout incrementally.

Beta
HKLiveWorkoutBuilder

A builder object that constructs a workout incrementally based on live data from an active workout session.

Beta

Activity Rings

HKActivitySummary

An object that contains the move, exercise, and stand data for a given day.

HKActivitySummaryQuery

A query for read activity summary objects from the HealthKit store.

HKActivityRingView

A view that uses the Move, Exercise, and Stand activity rings to display data from a HealthKit activity summary object.

Route Data

Creating a Workout Route

Record the user’s route during a workout.

Reading Route Data

Access the user’s route for a workout.

HKWorkoutRouteBuilder

A builder object that incrementally constructs a workout route.

HKWorkoutRoute

A sample that contains a workout’s route data.

HKWorkoutRouteQuery

A query to access the location data stored in a workout route.

HKWorkoutRouteTypeIdentifier

A series sample containing location data that defines the route the user took during a workout.

HKSeriesBuilder

An abstract base class for building series samples.

HKSeriesSample

An abstract base class that defines samples that contain a series of items.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software