API reference

Achievements Class

Modifiers: final
The Achievements API enables developers to create engaging experiences by awarding trophies, badges, and awards for reaching goals. Users can see friends' achievements Achievements.getAllDefinitions, fostering competition, and earned achievements are displayed in Meta Quest Home, showcasing progress Achievements.unlock and driving engagement.

Signature

class Achievements

Constructors

Achievements ()
Signature
constructor()
Returns
Achievements

Methods

addCount ( name , count )
Add 'count' to the achievement with the given name. This must be a COUNT achievement. The largest number that is supported by this method is the max value of a signed 64-bit integer. If the number is larger than that, it is clamped to that max value before being passed to the servers.
This method can return the following status codes: common status codes in AchievementsStatusCode.
Signature
suspend fun addCount(name: String, count: ULong): AchievementUpdate
Parameters
name: String  The api_name of the achievement that will be adding count, which can be retrieved by horizon.platform.achievements.models.AchievementDefinition.api_name.
count: ULong  The value of count that will be added to the achievement.
Returns
AchievementUpdate  The updated achievement progress.
addFields ( name , fields )
Unlock fields of a BITFIELD achievement.
This method can return the following status codes: common status codes in AchievementsStatusCode.
Signature
suspend fun addFields(name: String, fields: String): AchievementUpdate
Parameters
name: String  The api_name of the Bitfield achievement whose field(s) will be unlocked, which can be retrieved by horizon.platform.achievements.models.AchievementDefinition.api_name.
fields: String  A string containing either '0' or '1' characters. Every '1' will unlock the field in the corresponding position.
Returns
AchievementUpdate  The updated achievement progress.
getAllDefinitions ( coroutineScope )
Retrieve all achievement definitions for the app, including their name, unlock requirements, and any additional details.
This method can return the following status codes: common status codes in AchievementsStatusCode.
Signature
fun getAllDefinitions(coroutineScope: CoroutineScope): PagedResults<AchievementDefinition>
Parameters
coroutineScope: CoroutineScope
Returns
PagedResults  A list of achievement definitions.
getAllProgress ( coroutineScope )
Retrieve the progress for the user on all achievements in the app.
This method can return the following status codes: common status codes in AchievementsStatusCode.
Signature
fun getAllProgress(coroutineScope: CoroutineScope): PagedResults<AchievementProgress>
Parameters
coroutineScope: CoroutineScope
Returns
PagedResults  A list of achievement progress.
getDefinitionsByName ( coroutineScope , names )
Retrieve the achievement definitions that match the specified names, including their name, unlock requirements, and any additional details.
This method can return the following status codes: common status codes in AchievementsStatusCode.
Signature
fun getDefinitionsByName(coroutineScope: CoroutineScope, names: List<String>): PagedResults<AchievementDefinition>
Parameters
coroutineScope: CoroutineScope
names: List  The api_names of the achievements used to retrieve the definition information, which can be retrieved by horizon.platform.achievements.models.AchievementDefinition.api_name.
Returns
PagedResults  A list of achievement definitions.
getProgressByName ( coroutineScope , names )
Retrieve the user's progress on the achievements that match the specified names.
This method can return the following status codes: common status codes in AchievementsStatusCode.
Signature
fun getProgressByName(coroutineScope: CoroutineScope, names: List<String>): PagedResults<AchievementProgress>
Parameters
coroutineScope: CoroutineScope
names: List  The api_names of the achievements used to retrieve the progress information, which can be retrieved by horizon.platform.achievements.models.AchievementDefinition.api_name.
Returns
PagedResults  A list of achievement progress.
unlock ( name )
Unlock the achievement with the given name. This can be of any achievement type: a simple unlock, count-based, or bitfield-based achievement. The Meta Quest Platform supports three types of achievements: simple, count and bitfield. Each achievement type has a different unlock mechanism. Simple achievements are all-or-nothing. They are unlocked by a single event or objective completion. For example, a simple achievement is unlocked when Frodo reaches Mount Doom. Count achievements are unlocked when a counter reaches a defined target. Define the AchievementDefinition.target to reach that triggers the achievement. For example, a target achievement is unlocked when Darth Vader chokes 3 disappointing Imperial officers. Bitfield achievements are unlocked when a target number of bits in a bitfield are set. Define the AchievementDefinition.target and AchievementDefinition.bitfieldLength that triggers the achievement. For example, a bitfield achievement is unlocked when Harry destroys 5 of the 7 Horcruxes.
This method can return the following status codes: common status codes in AchievementsStatusCode.
Signature
suspend fun unlock(name: String): AchievementUpdate
Parameters
name: String  The api_name of the achievement that will be unlocked, which can be retrieved by horizon.platform.achievements.models.AchievementDefinition.api_name.
Returns
AchievementUpdate  The updated achievement progress.