Contents

GKChallenge

A challenge issued by the local player to another player.

Declaration

class GKChallenge

Overview

Players can use Game Center to challenge other players to beat their scores and achievements that they earn in your game. When a player issues a challenge to another player, Game Center sends a push notification to the other player. That player can then accept or refuse the challenge. If the player accepts the challenge, Game Center adds the challenge to the player’s list of challenges. Later, if the player beats the challenge, Game Center notifies both players.

Game Center supports two kinds of challenges:

score challenge (GKScoreChallenge)

When a player challenges another player to beat their leaderboard score. When the player beats the score, Game Center issues a new score challenge to the player who initiated the challenge and continues issuing challenges between the players until a player refuses the challenge.

achievement challenge (GKAchievementChallenge)

When a player challenges another player to earn an achievement. This challenge ends when the player earns the achievement.

You never subclass the GKChallenge class directly. However, you can subclass GKScoreChallenge or GKAchievementChallenge to create specific kinds of challenges.

Enable Challenges

You must enable challenges for your game in App Store Connect before you can use the challenges features. For details, see Enable challenges in App Store Connect Help.

Load and Issue Challenges

You can load the challenges issued by the local player using the loadReceivedChallenges(completionHandler:) class method. You can issue challenges with the player’s permission using the challengeComposeController(withMessage:players:completion:) method in the GKLeaderboard.Entry, GKScore, or GKAchievement class.

Topics

Retrieving the List of Challenges to the Local Player

Examining Details about a Challenge

Declining a Challenge

Deprecated symbols

Initializers

See Also

Deprecated classes