Framework

Game​Kit

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

Overview

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

GameKit Features

GameKit provides you with the ability to create apps that allow players to interact with each other. Multiplayer apps allow your game to create realtime network matches. Players can invite other players to join their game. 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 simultaneously.Starting in iOS 10.0, GameKit provides the ability to create multiplayer and turn-based using GKGame​Session. Game sessions use a player's iCloud account to invite other players to a game, save game data, and transfer data between players. Game sessions fully support the tracking aspects of Game Center. Game Center offers a centralized game service that connects players to each other. Game Center implements many different features:

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

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

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

Game Center is available on iOS, macOS, and tvOS.

Use the legacy classes to support multiplayer and turn-based gaming in iOS 9.0, macOS 10.11, tvOS 9.0 and earlier. Multiplayer and turn-based apps are not compatible between game sessions and legacy classes. However, after updating an app to use game sessions, players still have access to existing achievements, leaderboards, and challenges after being authenticated as the local player.

Symbols

Adding Players

GKBase​Player

The top level player object containing basic identifying information for a player.

GKCloud​Player

The object representing the currently signed in iCloud user.

GKInvite​Event​Listener

An object that handles invite events from Game Center.

GKLocal​Player

An object representing the authenticated Game Center player running your game on a device.

GKLocal​Player​Listener

The protocol you implement to handle events for Game Center accounts.

GKPlayer

An object that provides information about a player on Game Center.

GKGame​Session

An object used for saving game data, inviting other players, and creating turn-based and realtime game apps.

Incorporating Achievements, Leaderboards, and Challenges

GKAchievement

An object that communicates with Game Center about the local player’s progress towards completing an achievement.

GKAchievement​Challenge

A challenge sent to another player urging them to complete a specific achievement.

GKAchievement​Description

An object holding text and images used to describe an achievement for an app.

GKChallenge

An object representing a challenge issued by the local player to another player.

GKChallenge​Listener

An object that responds to challenge events.

GKLeaderboard

An object used to read data from a leaderboard stored on Game Center.

GKLeaderboard​Set

An object that organizes leaderboards into logical and coherent groups.

GKScore

An object containing information for a score that was earned by the player.

GKScore​Challenge

An object representing a challenge based on a score in a leaderboard.

Working with Game Sessions

GKGame​Session

An object used for saving game data, inviting other players, and creating turn-based and realtime game apps.

GKGame​Session​Event​Listener

An object that handles game session events.

GKGame​Session​Sharing​View​Controller

An object that displays a user interface, allowing users to invite others into their tvOS game session.

GKGame​Session​Sharing​View​Controller​Delegate

The protocol you implement to respond to changes to a sharing user interface, represented by a GKGame​Session​Sharing​View​Controller.

Adding a Game Center View Controller

GKDialog​Controller

An object that provides the ability to present Game Center view controller classes in macOS.

GKGame​Center​View​Controller

A single user interface used to display achievements and leaderboards supported by Game Center.

GKGame​Center​Controller​Delegate

The delegate is called when the player dismisses the Game Center user interface.

GKView​Controller

An abstract base class for Game Center view controller classes.

Reference

Game​Kit Error Domains

The error code domains for GameKit.

Game​Kit Constants

GameKit constants affecting multiple classes.

Game​Kit Enumerations

GameKit enumerations affecting multiple classes.

Game​Kit Data Types

GameKit data types affecting multiple classes.

Deprecated APIs

GKAchievement​View​Controller

An GKAchievement​View​Controller object provides a standard user interface to display achievement progress for the local player. If the GKGame​Center​View​Controller class is available, you should use it instead.

Deprecated
GKChallenges​View​Controller​Delegate
GKFriend​Request​Compose​View​Controller

Your game uses the GKFriend​Request​Compose​View​Controller class to present a screen that allows the local player to send friend requests to other players.

Deprecated
GKFriend​Request​Compose​View​Controller​Delegate

The GKFriend​Request​Compose​View​Controller​Delegate protocol is implemented by delegates of the GKFriend​Request​Compose​View​Controller class. The delegate is called when the player dismisses the friend request.

GKLeaderboard​View​Controller

The GKLeaderboard​View​Controller class provides a standard user interface that displays leaderboard scores to the player. If the GKGame​Center​View​Controller class is available, you should use it instead.

Deprecated
GKPeer​Picker​Controller​Delegate

The GKPeer​Picker​Controller​Delegate protocol is implemented on an object to customize the behavior of a GKPeer​Picker​Controller 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.

GKSession

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

Deprecated
GKSession​Delegate

An object implements the GKSession​Delegate 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.

GKTurn​Based​Event​Handler

The GKTurn​Based​Event​Handler 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 GKTurn​Based​Event​Handler​Delegate protocol to its delegate property. All methods are called on the main thread.

Deprecated
GKVoice​Chat​Client

The GKVoice​Chat​Client protocol is implemented to control the behavior of the GKVoice​Chat​Service object. The voice chat client has a number of responsibilities:

GKVoice​Chat​Service

The GKVoice​Chat​Service class allows your application to connect two iOS devices into a voice chat.

Deprecated

See Also

Related Documentation