GKAchievement
An achievement you can award a player as they make progress toward and reach a goal in your game.
Declaration
class GKAchievementMentioned in
Overview
Before using this class, configure your game achievements in App Store Connect. Then the dashboard shows the achievements initially locked and you can access them in your code.
Use the loadAchievements(completionHandler:) method to load all the achievements that the local player is progressing toward. If an achievement doesn’t load, then it’s the first time you’re reporting the player’s progress toward it, and you must create a GKAchievement object to represent it. Next, set the percentage complete of the achievement using the percentComplete property.
You can report the player’s progress for one or more achievements to Game Center using the report(_:withCompletionHandler:) method. The dashboard changes the appearance of the achievements to show the current percentages. If you set the percentage of an achievement to 100, the dashboard shows it as completed.
To reset the player’s progress on all achievements, use the resetAchievements(completionHandler:) class method.
Topics
Loading and Initializing Achievements
Accessing Achievement Properties
Reporting Progress on Achievements
report(_:withCompletionHandler:)report(_:withEligibleChallenges:withCompletionHandler:)showsCompletionBannerresetAchievements(completionHandler:)
Issuing Achievement Challenges
selectChallengeablePlayers(_:withCompletionHandler:)challengeComposeController(withMessage:players:completion:)GKChallengeComposeHandlerchallengeComposeController(withMessage:players:completionHandler:)challengeComposeController(withPlayers:message:completionHandler:)