GPGAchievement Class Reference

GPGAchievement Class Reference

Overview

An object that represents the completion of a task or goal.

Achievement objects must be created with an achievement ID. Once an achievement object is created, you may interact with it using the provided set of actions.

Properties

Constant Properties
NSString * achievementId
 The unique identifier for this achievement object.
Configurable Properties
BOOL showsCompletionNotification
 Whether or not to display a visual notification when this achievement is unlocked.

Initialization

(instancetype) - initWithAchievementId:
 Initializes a newly allocated achievement object with the given achievement identifier.
(instancetype) + achievementWithId:
 Convenience method for initWithAchievementId:.

Actions

(void) - unlockAchievementWithCompletionHandler:
 Initiates a request to mark this achievement as unlocked.
(void) - revealAchievementWithCompletionHandler:
 Initiates a request to reveal this achievement.
(void) - incrementAchievementNumSteps:completionHandler:
 Initiates a request to increment this achievement.
(void) - setSteps:completionHandler:
 Initiates a request to set number of steps this achievement.
(void) - resetAchievementWithCompletionHandler:
 Initiates a request to reset the state of this achievement.
(void) + resetAllAchievementsWithCompletionHandler:
 Initiates a request to reset the state of all achievements for this player.

Member Function Documentation

- (instancetype) initWithAchievementId: (NSString *)  achievementId

Initializes a newly allocated achievement object with the given achievement identifier.

This is the designated initializer.

Parameters:
achievementIdThe achievement identifier to bind to this object.
Returns:
The GPGAchievement object initialized with the given achievement identifier. Designated initializer.
+ (instancetype) achievementWithId: (NSString *)  achievementId

Convenience method for initWithAchievementId:.

Parameters:
achievementIdThe achievement identifier to bind to this object.
Returns:
A newly allocated and initialized GPGAchievement object.
- (void) unlockAchievementWithCompletionHandler: (GPGAchievementDidUnlockBlock)  completionHandler

Initiates a request to mark this achievement as unlocked.

If showsCompletionNotification is YES and this achievement has not previously been unlocked, then an achievement completion notification will be shown immediately.

The completionHandler block will be called upon completion of the request. If the request fails in any way then the error parameter will be non-nil and newlyUnlocked undefined.

Completing an achievement implicitly reveals it. Calling the unlock action will cancel any active reveal actions.

If the device is offline when an achievement is unlocked then the achievement's state will be synced with the Google Play Games server once the Internet connection returns. The achievement will still be marked as unlocked locally.

Parameters:
completionHandler(optional) A block of the form: ^(BOOL newlyUnlocked, NSError *error). newlyUnlocked will be YES if the achievement was newly unlocked after this request was made.
- (void) revealAchievementWithCompletionHandler: (GPGAchievementDidRevealBlock)  completionHandler

Initiates a request to reveal this achievement.

The completionHandler block will be called upon completion of the request. If the request fails in any way then the error parameter will be non-nil.

If the device is offline when an achievement is revealed then the achievement's state will be synced with the Google Play Games server once the Internet connection returns.

Parameters:
completionHandler(optional) A block of the form: ^(GPGAchievementState state, NSError *error).
- (void) incrementAchievementNumSteps: (NSInteger)  steps
completionHandler: (GPGAchievementDidIncrementBlock)  completionHandler 

Initiates a request to increment this achievement.

The completionHandler block will be called upon completion of the request. If the request fails in any way then the error parameter will be non-nil.

If the device is offline when an achievement is incremented then the achievement's state will be synced with the Google Play Games server once the Internet connection returns.

Parameters:
stepsThe number of steps by which to increment this partial achievement.
completionHandler(optional) A block of the form: ^(BOOL newlyUnlocked, int currentSteps, NSError *error).
- (void) setSteps: (NSInteger)  steps
completionHandler: (GPGAchievementDidSetStepsBlock)  completionHandler 

Initiates a request to set number of steps this achievement.

Set an achievement to have at least the given number of steps completed. Calling this method while the achievement already has more steps than the provided value is a no-op. Once the achievement reaches the maximum number of steps, the achievement will automatically be unlocked, and any further mutation operations will be ignored.

The completionHandler block will be called upon completion of the request. If the request fails in any way then the error parameter will be non-nil.

If the device is offline then the achievement's state will be synced with the Google Play Games server once the Internet connection returns.

Parameters:
stepsThe number of steps to set for this incremental achievement.
completionHandler(optional) A block of the form: ^(BOOL newlyUnlocked, int currentSteps, NSError *error).
- (void) resetAchievementWithCompletionHandler: (GPGAchievementDidResetBlock)  completionHandler

Initiates a request to reset the state of this achievement.

We only include v1management APIs in our next version.

This can only be called if the calling player is a trusted tester of the game.

The completionHandler block will be called upon completion of the request. If an error occurred, this parameter holds an error object that describes the problem. If the achievement was successfully reset, this parameter’s value is nil.

If the device is offline when an achievement is reset, the completionHandler will receive an error with the code GPGNetworkUnavailableError.

Parameters:
completionHandler(optional) A block of the form: ^(NSError *error).
+ (void) resetAllAchievementsWithCompletionHandler: (GPGAllAchievementsDidResetBlock)  completionHandler

Initiates a request to reset the state of all achievements for this player.

This can only be called if the calling player is a trusted tester of the game.

The completionHandler block will be called upon completion of the request. If an error occurred, this parameter holds an error object that describes the problem. If the achievements were successfully reset, this parameter’s value is nil.

If the device is offline when achievements are reset, the completionHandler will receive an error with the code GPGNetworkUnavailableError.

Parameters:
completionHandler(optional) A block of the form: ^(NSError *error).

Property Documentation

- (NSString*) achievementId [read, copy]

The unique identifier for this achievement object.

- (BOOL) showsCompletionNotification [read, write, assign]

Whether or not to display a visual notification when this achievement is unlocked.

An achievement notification will only be shown once for a given achievement.

By default this is YES.

Send feedback about...

Play Games Services for iOS
Play Games Services for iOS