Class

GKLocalPlayer

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

Declaration

@interface GKLocalPlayer : GKPlayer

Overview

At any given time, only one player may be authenticated on the device; this player must log out before another player can log in. Your game must authenticate the local player before using any Game Center features. Authenticating the player ensures that the player has created an account and is connected to Game Center. To authenticate the local player, retrieve the shared instance of the local player by calling the localPlayer class method and set its authenticateHandler property.

You can see whether the local player is authenticated by reading the authenticated property. If authenticated is YES, then the local player’s other properties are valid, and you can call other Game Center methods.

Topics

Accessing the Shared Local Player

- loadRecentPlayersWithCompletionHandler:

Returns an array of players the local player recently played with.

localPlayer

Retrieves the shared instance of the local player.

Authentication

authenticateHandler

A handler called to process an authentication-related event.

authenticated

A Boolean value that indicates whether a local player is currently signed in to Game Center.

- generateIdentityVerificationSignatureWithCompletionHandler:

Generates a signature that allows a third party server to authenticate the local player.

Determining Whether the Player Is Underage

underage

A Boolean value that declares whether the local player is underage.

Working with Leaderboards

- loadDefaultLeaderboardIdentifierWithCompletionHandler:

Loads the category identifier for the local player’s default leaderboard.

- setDefaultLeaderboardIdentifier:completionHandler:

Sets the default leaderboard for the current game.

Registering Listeners

- registerListener:

Register a listener for a particular event.

- unregisterAllListeners

Unregister all listeners in your game.

- unregisterListener:

Unregister a specific listener.

Working with Saved Games

- deleteSavedGamesWithName:completionHandler:

Deletes a specific saved game file.

- fetchSavedGamesWithCompletionHandler:

Retrieves all available saved games.

- saveGameData:withName:completionHandler:

Saves game data under the specified name.

Deprecated Methods and Properties

- authenticateWithCompletionHandler:

Authenticates the local player on the device.

Deprecated
friends

An array of NSString objects containing the player identifiers for the local player’s friends.

Deprecated
- loadDefaultLeaderboardCategoryIDWithCompletionHandler:

Loads the category identifier for the local player’s default leaderboard.

Deprecated
- loadFriendPlayersWithCompletionHandler:

Retrieves a list of player identifiers for the local player’s friends.

Deprecated
- loadFriendsWithCompletionHandler:

Retrieves a list of player identifiers for the local player’s friends.

Deprecated
- setDefaultLeaderboardCategoryID:completionHandler:

Sets the category identifier for the local player’s default leaderboard.

Deprecated

Notifications

GKPlayerAuthenticationDidChangeNotificationName

Posted after the authenticated property of the shared local player object changes. The object property for this notification is a GKLocalPlayer object. Passing nil provides standard Notification Center behavior which is to receive the notification for any object.

Instance Properties

Type Properties

Relationships

Inherits From

See Also

Players

GKPlayer

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

GKBasePlayer

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

GKLocalPlayerListener

A protocol that handles events for Game Center accounts.

GKInviteEventListener

A protocol that handles invite events from Game Center.