Framework

GameKit

Create experiences that keep players coming back to your game. Add leaderboards, achievements, matchmaking, challenges, and more.

Overview

Game Kit offers features that you can use to create great social games.

Game Kit Features

Game Kit provides three separate pieces of functionality:

  • Game Center offers a centralized game service that connects players to each other. Game Center implements many different features:

    • Friends allow players to create anonymous online personas. Users connect to Game Center and interact with other players through an alias. Players can set status messages as well as mark other players as friends.

    • Multiplayer allows your game to create network matches that connect players through Game Center. Players can invite their friends or be connected to anonymous players. Most importantly, players can receive invitations to join a match even when your game is not running. Your game is running on each device and the instances of your game exchange match and voice data with each other.

    • Turn-Based Gaming provides store-and-forward network match infrastructure where the match is played out over a series of discrete turns. This kind of match can be played without requiring all of the players to be connected to Game Center simultaneously.

    • Leaderboards allow your game to store and fetch player scores from Game Center.

    • Achievements provide the ability to track a player’s accomplishments in your game.

    • Challenges allow a player to challenge other players to complete an achievement or to beat a leaderboard score.

    Game Center is available on iOS and macOS.

  • Peer-to-peer connectivity allows your game to create an ad hoc Bluetooth or wireless network between multiple iPhones in the same local area. Although designed with games in mind, this network is useful for any type of data exchange among users of your app. For example, an app could use peer-to-peer connectivity to share electronic business cards or other data. This functionality is only available on iOS. You can also get the same functionality using Game Center.

  • In-game voice chat allows your game to provide voice communication between two iPhones. In-game voice relies on your game’s network connection to another user to create its own network connection to transmit voice data. This functionality is only available on iOS. You can also get the same functionality using Game Center.

Symbols

Classes

GKAchievement

Your game uses a GKAchievement object to communicate with Game Center about the local player’s progress towards completing an achievement.

GKAchievementChallenge

A GKAchievementChallenge is a challenge to a player to complete a specific achievement.

GKAchievementDescription

An GKAchievementDescription object holds text and images used to describe an achievement. When you develop your game, you create localized achievement descriptions in iTunes Connect. At runtime, your game retrieves these descriptions from Game Center. Usually your game downloads the achievement descriptions when it wants to present a custom achievement user interface to the player.

GKAchievementViewController

An GKAchievementViewController object provides a standard user interface to display achievement progress for the local player. If the GKGameCenterViewController class is available, you should use it instead.

Deprecated
GKBasePlayer
GKChallenge

A GKChallenge object represents a challenge issued by a player to another player.

GKCloudPlayer
GKDialogController

The GKDialogController class provides the ability to present Game Center view controller classes in macOS. iOS games present the view controllers using the normal presentation methods provided by the UIViewController class.

GKFriendRequestComposeViewController

Your game uses the GKFriendRequestComposeViewController class to present a screen that allows the local player to send friend requests to other players.

Deprecated
GKGameCenterViewController

The GKGameCenterViewController class aggregates many common Game Center features into a single user interface. It replaces GKAchievementViewController and GKLeaderboardViewController as the preferred way to show Game Center content in your game.

GKGameSessionGKGameSessionSharingViewController
GKInvite

A GKInvite object represents a matchmaking invitation sent by another player to the local player. Your game never directly creates GKInvite objects. Instead, these objects are created by GameKit and delivered to your game’s matchmaking event handler. See GKMatchmaker.

GKLeaderboard

A GKLeaderboard object is used to read data from a leaderboard stored on Game Center. Your game uses GKLeaderboard objects when it wants to retrieve localized information about a specific leaderboard or to retrieve scores from a leaderboard. Typically, you do this when you want the data needed to implement your own custom leaderboard user interface.

GKLeaderboardSet

Add leaderboard sets to your app and organize your leaderboards into logical and coherent groups. Once you incorporate leaderboard sets into your app, you must put all of your leaderboards into a set. Individual leaderboards can be put into multiple leaderboard sets and given different display names in each set.

GKLeaderboardViewController

The GKLeaderboardViewController class provides a standard user interface that displays leaderboard scores to the player. If the GKGameCenterViewController class is available, you should use it instead.

Deprecated
GKLocalPlayer

The GKLocalPlayer class is a special subclass of GKPlayer that represents the authenticated player running your game on the device. At any given time, only one player may be authenticated on the device; this player must log out before another player can log in.

GKMatch

A GKMatch object provides a peer-to-peer network between a group of devices that are connected to Game Center. Matches provide transmit both voice and game data. Your game never directly allocates GKMatch objects. Instead, it uses the GKMatchmaker class to programmatically find a match with other interested players or a GKMatchmakerViewController object to display a user interface to the player.

GKMatchmaker

The GKMatchmaker class is used to programmatically create matches to other players and to receive match invitations sent by other players.

GKMatchmakerViewController

The GKMatchmakerViewController class is used to present a standard user interface to the player. This interface allows them to invite friends to a match or to allow Game Center to fill the remaining players needed for a match.

GKMatchRequest

A GKMatchRequest object is used to specify the parameters for a new live or turn-based match. You initialize a match request object, then pass it to another object to actually create the match. The kind of object you pass it to depends on which kind of match you want and whether you want to display the standard matchmaking user interface. See Table 1.

GKNotificationBanner

The GKNotificationBanner class allows your game to display a notification banner that displays text to the player. The behavior of this banner is identical to other banners used by Game Kit.

GKPlayer

GKPlayer objects provide information about a player on Game Center.

GKSavedGame

A GKSavedGame object contains the metadata for identifying a saved game and a method for loading a previously saved game.

GKScore

A GKScore class holds information for a score that was earned by the player. Your game creates GKScore objects to post scores to a leaderboard on Game Center. When your game retrieves score information from a leaderboard, those scores are returned as GKScore objects.

GKScoreChallenge

A GKScoreChallenge object represents a challenge based on a score in a leaderboard. To complete the challenge, the player must score an equal or better score than the score used to create the challenge. When a player beats a score challenge, a new score challenge is automatically issued to the player that issued the challenge unless there is already a pending score challenge that requires a better score.

GKSession

A GKSession object provides the ability to discover and connect to nearby iOS devices using Bluetooth or Wi-fi.

Deprecated
GKTurnBasedEventHandler

The GKTurnBasedEventHandler class is used to respond to important messages related to turn-based matches. To use it, call the shared() class method to get the Singleton instance and assign an object that implements the GKTurnBasedEventHandlerDelegate protocol to its delegate property. All methods are called on the main thread.

Deprecated
GKTurnBasedExchange

A GKTurnBasedExchange object provides developers with a way to expand how turn based matches are currently played by allowing players to send information even when they are not the current player.

GKTurnBasedExchangeReply

Describes a GKTurnBasedExchangeReply object that contains a player’s response to an exchange.

GKTurnBasedMatch

The GKTurnBasedMatch class allows your game to implement turn-based matches between sets of players on Game Center. A turn-based match uses a store-and-forward approach to share data between the participants. When a player participating in the match performs actions that advance the state of the match, your game describes the new state of the match and decides which player acts next. The next player to act is notified by a push notification. Later, when the next player launches your game, you download the match data from Game Center and continue the match. Players take turns acting (based on whatever internal logic your game implements) until the match ends. One advantage of turn-based matches is that a player may participate in multiple matches simultaneously.

GKTurnBasedMatchmakerViewController

The GKTurnBasedMatchmakerViewController class displays a user interface that allows players to manage the turn-based matches that they are participating in.

GKTurnBasedParticipant

A GKTurnBasedParticipant object stores information for a participant in a turn-based match. Your game never creates objects of this class directly; instead it retrieves an array of GKTurnBasedParticipant objects from a GKTurnBasedMatch object.

GKVoiceChat

A GKVoiceChat object provides a voice channel that allows a set of players in a match to speak with each other.

GKVoiceChatService

The GKVoiceChatService class allows your application to connect two iOS devices into a voice chat.

Deprecated

Protocols

GKChallengeListener

Provides methods for responding to challenge events. Your app can ignore a challenge, start up in a specific state so the player can respond to a challenge, or notify the original challenger when the local player completes a challenge.

GKChallengesViewControllerDelegate
GKFriendRequestComposeViewControllerDelegate

The GKFriendRequestComposeViewControllerDelegate protocol is implemented by delegates of the GKFriendRequestComposeViewController class. The delegate is called when the player dismisses the friend request.

GKGameCenterControllerDelegate

The GKGameCenterControllerDelegate protocol is implemented by delegates of the GKGameCenterViewController class. The delegate is called when the player dismisses the Game Center user interface.

GKGameSessionEventListenerGKGameSessionSharingViewControllerDelegate
GKInviteEventListener

Handles invite invite events form Game Center. You can invite other players and start your game from directly from Game Center. Accepting an invitation begins the game from Game Center with the accepting player assigned a spot in the game.

GKLocalPlayerListener

The GKLocalPlayerListener protocol inherits the methods from GKChallengeListener, GKInviteEventListener, and GKTurnBasedEventListener in order to handle multiple events.

GKMatchDelegate

The GKMatchDelegate protocol is implemented to receive status updates and network data from players connected to a GKMatch object.

GKMatchmakerViewControllerDelegate

A class implements the GKMatchmakerViewControllerDelegate protocol to receive notifications from a GKMatchmakerViewController object. The delegate is called if a new match has been successfully created, if the user cancels matchmaking, and if an error occurs. In all three cases, the delegate should dismiss the view controller.

GKPeerPickerControllerDelegate

The GKPeerPickerControllerDelegate protocol is implemented on an object to customize the behavior of a GKPeerPickerController object. The delegate is called by the peer picker to create a session object and to respond as the session is configured by the controller.

GKSavedGameListener

Override the methods in the GKSavedGameListener protocol to provide custom actions when a saved game file is modified or a conflict is found.

GKSessionDelegate

An object implements the GKSessionDelegate protocol to control the behavior of a GKSession object. The delegate is called when other visible peers change their state relative to the session. It is also called to determine whether another peer is allowed to connect to the session.

GKTurnBasedEventListener

Handles events for turn-based games. Provides methods for responding to exchanges and match events.

GKTurnBasedMatchmakerViewControllerDelegate

Your game implements the GKTurnBasedMatchmakerViewControllerDelegate protocol on an object to respond to events generated by a GKTurnBasedMatchmakerViewController object.

GKViewController
GKVoiceChatClient

The GKVoiceChatClient protocol is implemented to control the behavior of the GKVoiceChatService object. The voice chat client has a number of responsibilities:

See Also

Related Documentation