Achievements - pogamesdk/POGAME-HTML5 GitHub Wiki
Achievements
Unlock rewards and recognition with POGAME SDK Achievements.
For the requests below to work, make sure that:
- You've enabled and configured the SDK, and its object is available via the
posdk
variable. - You've created some Achievements for your game in the Games Console.
Create Achievements
-
Go to the Games Console.
-
Select the game.
-
Open the
Achievements
tab and click toAdd
button. -
Fill in the fields:
Field | Description |
---|---|
name | Achievement name. |
description | A short description about the achievement. |
avatar | A avatar let players display unique icons representing their in-game milestones. |
- Click Submit.
This will create an achievement. You can create multiple achievements.
Implementation
Initialization
To initialize the ach
object, use the posdk.getAchievements()
method:
var ach;
posdk.getAchievements()
.then(_ach => ach = _ach);
Achievement description
To get a description of an achievement by its code, use the getAchievementDescription
method.
posdk.getAchievements()
.then(ach => ach.getAchievementDescription('achievement_Fsa7d6'))
.then(res => console.log(res));
Parameter | Description |
---|---|
achievementCode | Achievement code. Its was generated when uploading your game. |
Response format
{
id: integer,
code: string,
name: string,
description: string,
avatar: string,
claimed: boolean
}
Parameter | Description |
---|---|
id | Achievement ID. |
code | Achievement code. |
name | Achievement name. |
description | Short description of the achievement. |
avatar | Image url of avatar. |
claimed | Is the current player has claimed this achievement. |
Claim achievement
To save achievement for a player, use the claimAchievement()
method.
Parameter | Description |
---|---|
achievementCode | Achievement code. Its was generated when uploading your game. |
posdk.getAchievements()
.then(ach => {
ach.claimAchievement('achievement_Fsa7d6');
});
Achievement entries
To display users' reward, use the getAchievementEntries
method:
posdk.getAchievements()
.then(ach => {
ach.getAchievementEntries('achievement_Fsa7d6')
.then(res => console.log(res));
});
Reponse format
{
entries: [
{
id: integer,
code: string,
name: string,
description: string,
avatar: string,
claimed: boolean
}
]
}
Parameter | Description |
---|---|
entries | Requested entries. |
claimed | Is the current player has claimed the achievement? |
If you are facing an issue or have a question regarding the use of POGAME SDK, please contact support: mailto:[email protected]