Framework

GameKit

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 GKGameSession. 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

GKBasePlayer

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

GKCloudPlayer

The object representing the currently signed in iCloud user.

GKInviteEventListener

An object that handles invite events from Game Center.

GKLocalPlayer

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

GKLocalPlayerListener

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

GKPlayer

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

GKGameSession

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.

GKAchievementChallenge

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

GKAchievementDescription

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.

GKChallengeListener

An object that responds to challenge events.

GKLeaderboard

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

GKLeaderboardSet

An object that organizes leaderboards into logical and coherent groups.

GKScore

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

GKScoreChallenge

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

Working with Game Sessions

GKGameSession

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

GKGameSessionEventListener

An object that handles game session events.

GKGameSessionSharingViewController

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

GKGameSessionSharingViewControllerDelegate

The protocol you implement to respond to changes to a sharing user interface, represented by a GKGameSessionSharingViewController.

Adding a Game Center View Controller

GKDialogController

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

GKGameCenterViewController

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

GKGameCenterControllerDelegate

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

GKViewController

An abstract base class for Game Center view controller classes.

Reference

GameKit Error Domains

The error code domains for GameKit.

GameKit Constants

GameKit constants affecting multiple classes.

GameKit Enumerations

GameKit enumerations affecting multiple classes.

GameKit Data Types

GameKit data types affecting multiple classes.

Deprecated APIs

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
GKChallengesViewControllerDelegate
GKFriendRequestComposeViewController

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

Deprecated
GKFriendRequestComposeViewControllerDelegate

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

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
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.

GKSession

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

Deprecated
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.

GKSessionErrorDeprecated
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
GKVoiceChatClient

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

GKVoiceChatService

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

Deprecated

See Also

Related Documentation