<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameKit",
  "identifier" : "/documentation/GameKit/GKGameActivity",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "GameKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKGameActivity"
  },
  "title" : "GKGameActivity"
}
-->

# GKGameActivity

An object that represents a single instance of a game activity for the current game.

```
class GKGameActivity
```

## Topics

### Creating an activity

[`init(definition:)`](/documentation/GameKit/GKGameActivity/init(definition:))

Creates a game activity with definition.

[`start(definition:)`](/documentation/GameKit/GKGameActivity/start(definition:))

Creates and starts a game activity with a definition.

[`start(definition:partyCode:)`](/documentation/GameKit/GKGameActivity/start(definition:partyCode:))

Creates and starts a new game activity with a custom party code.

### Getting the activity definition

[`activityDefinition`](/documentation/GameKit/GKGameActivity/activityDefinition)

The activity definition that this activity instance is based on.

### Getting the activity state

[`state`](/documentation/GameKit/GKGameActivity/state-swift.property)

The state of the game activity.

[`GKGameActivity.State`](/documentation/GameKit/GKGameActivity/State-swift.enum)

The state of a game activity.

### Updating the activity state

[`start()`](/documentation/GameKit/GKGameActivity/start())

Starts the game activity if it’s not already started.

[`pause()`](/documentation/GameKit/GKGameActivity/pause())

Pauses the game activity if it’s not already paused.

[`resume()`](/documentation/GameKit/GKGameActivity/resume())

Resumes the game activity if it was paused.

[`end()`](/documentation/GameKit/GKGameActivity/end())

Ends the game activity if it’s not already ended.

### Getting and removing achievements

[`achievements`](/documentation/GameKit/GKGameActivity/achievements)

All achievements that have been associated with this activity.

[`removeAchievements(_:)`](/documentation/GameKit/GKGameActivity/removeAchievements(_:))

Removes all achievements if they exist.

[`progress(on:)`](/documentation/GameKit/GKGameActivity/progress(on:))

Get the achievement progress from a specific achievement of the local player if previously set.

[`setProgress(on:to:)`](/documentation/GameKit/GKGameActivity/setProgress(on:to:))

Set a progress for an achievement for a player.

[`setAchievementCompleted(_:)`](/documentation/GameKit/GKGameActivity/setAchievementCompleted(_:))

Set progress to 100% for an achievement for a player.

### Getting and removing leaderboard scores

[`leaderboardScores`](/documentation/GameKit/GKGameActivity/leaderboardScores)

All leaderboard scores that have been associated with this activity.

[`score(on:)`](/documentation/GameKit/GKGameActivity/score(on:))

Get the leaderboard score from a specific leaderboard of the local player if previously set.

[`setScore(on:to:)`](/documentation/GameKit/GKGameActivity/setScore(on:to:))

Set a score of a leaderboard for a player.

[`setScore(on:to:context:)`](/documentation/GameKit/GKGameActivity/setScore(on:to:context:))

Set a score of a leaderboard with a context for a player.

[`removeScores(from:)`](/documentation/GameKit/GKGameActivity/removeScores(from:))

Removes all scores from leaderboards for a player if exist.

### Getting and verifying the party code

[`partyCode`](/documentation/GameKit/GKGameActivity/partyCode)

If the game supports party code, this is the party code that can be shared among players to join the party.

[`partyURL`](/documentation/GameKit/GKGameActivity/partyURL)

If the game supports party code, this is the URL that can be shared among players to join the party.

[`validPartyCodeAlphabet`](/documentation/GameKit/GKGameActivity/validPartyCodeAlphabet)

Allowed characters for the party code to be used to share this activity.

[`isValidPartyCode(_:)`](/documentation/GameKit/GKGameActivity/isValidPartyCode(_:))

Checks whether a party code is in valid format.

### Getting the activity properties

[`duration`](/documentation/GameKit/GKGameActivity/duration)

The total time elapsed while in active state.

[`startDate`](/documentation/GameKit/GKGameActivity/startDate)

The date when the activity was initially started.

[`endDate`](/documentation/GameKit/GKGameActivity/endDate)

The date when the activity was officially ended.

[`creationDate`](/documentation/GameKit/GKGameActivity/creationDate)

The date when the activity was created.

[`lastResumeDate`](/documentation/GameKit/GKGameActivity/lastResumeDate)

The date when the activity was last resumed.

### Getting the custom user data

[`properties`](/documentation/GameKit/GKGameActivity/properties)

Properties that contain additional information about the activity.

### Getting the activity identifiers

[`identifier`](/documentation/GameKit/GKGameActivity/identifier)

The identifier of this activity instance.

### Checking for an activity

[`checkPendingGameActivityExistence(completionHandler:)`](/documentation/GameKit/GKGameActivity/checkPendingGameActivityExistence(completionHandler:))

Checks whether there is a pending activity to handle for the current game.

### Creating a matchmaking request

[`makeMatchRequest()`](/documentation/GameKit/GKGameActivity/makeMatchRequest())

Makes a match request object with information from the activity, which you can use to find matches for the local player.

### Performing a matchmaking request

[`findMatch(completionHandler:)`](/documentation/GameKit/GKGameActivity/findMatch(completionHandler:))

Use information from the activity to find matches for the local player.

[`findPlayersForHostedMatch(completionHandler:)`](/documentation/GameKit/GKGameActivity/findPlayersForHostedMatch(completionHandler:))

Use information from the activity to find server hosted players for the local player.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)