Contents

GKPlayer

A remote player who the local player running your game can invite and communicate with through Game Center.

Declaration

class GKPlayer

Mentioned in

Overview

Before using Game Center for the first time, players create a single account that identifies them across all Game Center games. The player only needs to sign in to Game Center once per device to start using GameKit features in your game. A player sets a nickname and avatar in their account that provide a consistent and familiar look in your game. Game Center then uses the account to record leaderboard scores and achievements, and to start games with other players.

In your code, GKPlayer represents remote or other players who the local player running your app can invite and communicate with. GKPlayer is also the superclass for the local player GKLocalPlayer class that provides common data and methods for all players. For example, use the alias property to get the nickname for a player. To load the player avatars, use the loadPhoto(for:withCompletionHandler:) method.

To create a guest player who doesn’t have a Game Center account, use the anonymousGuestPlayer(withIdentifier:) method. GameKit treats guest players similar to Game Center players except they can’t earn achievements, post to leaderboards, or participate in challenges.

Use the gamePlayerID property as a unique identifier for just your game, and the teamPlayerID property as a unique identifier for all games that you offer through your developer account. For more information, see Protecting the player’s privacy using scoped identifiers.

Topics

Identifying the player

Accessing player details

Loading player photos

Creating a guest player

Observing notifications

Loading player details

See Also

Players