Instance Method

reportAchievementWithCompletionHandler:

Reports the player’s progress to Game Center.

Declaration

- (void)reportAchievementWithCompletionHandler:(void (^)(NSError *error))completionHandler;

Parameters

completionHandler

A block to be called after the operation completes.

The block takes the following parameter:

error

If the operation was successful, this value is nil; otherwise, this parameter holds an object that describes the problem that occurred.

Discussion

When the player makes progress towards completing an achievement, your game communicates the player’s progress to Game Center by calling this method. An achievement object is implicitly tied to the local player that was authenticated when the object was created; your game should only report progress when the same local player is still authenticated on the device.

When the progress is successfully reported, the achievement is made visible if it was previously hidden. The percentComplete and lastReportedDate property values stored on Game Center are updated if the new percentComplete value is greater than the value previously stored on Game Center. if the value of the percentComplete property was equal to 100.0, then the achievement is marked as completed and a banner may be shown to the player.

When this method is called, it creates a new background task to handle the request. The method then returns control to your game. The background task automatically handles network errors, resending the data until the task completes. When the task is complete, Game Kit calls your completion handler. The completion handler is always called on the main thread.

See Also

Deprecated Methods and Properties

- challengeComposeControllerWithPlayers:message:completionHandler:

Provides a challenge compose view controller with pre-selected player identifiers and a message.

Deprecated
hidden

A Boolean value that states whether this achievement is normally kept secret from the player.

Deprecated
- initWithIdentifier:forPlayer:

Initializes an achievement for a specific player.

Deprecated
- issueChallengeToPlayers:message:

Issue an achievement challenge to a list of players.

Deprecated
playerID

A string used to identify the player who earned the achievement.

Deprecated
- selectChallengeablePlayerIDs:withCompletionHandler:

Finds the subset of players that can earn an achievement.

Deprecated