Skip to main content
Version: 5.7.0

PostScoreToDynamicLeaderboardUsingConfig

Post the player's score to the given social leaderboard, dynamically creating the leaderboard if it does not exist yet. To create new leaderboard, configJson must specify leaderboardType, rotationType, resetAt, and retainedCount, at a minimum, with support to optionally specify an expiry in minutes.

ServiceOperation
leaderboardPOST_SCORE_DYNAMIC_USING_CONFIG
info

This new API call has been added to provide increased flexibility compared to the previous methods. It enables the developer to set a parameter of expireInMins, which queues the leaderboard for deletion after the designated number of minutes.

Method Parameters

ParameterDescription
leaderboardIdThe leaderboard to post to.
scoreA score to post.
scoreDataOptional user-defined data to post with the score.
configJsonConfiguration for the leaderboard if it does not exist yet, specified as JSON object. The supporting configuration fields are listed in the following table of configJson fields.

configJson fields

ParameterDescription
leaderboardTypeRequired. Type of leaderboard. Valid values are 'LAST_VALUE', 'HIGH_VALUE', 'LOW_VALUE', 'CUMULATIVE', 'ARCADE_HIGH', 'ARCADE_LOW';
rotationTypeRequired. Type of rotation. Valid values are 'NEVER', 'DAILY', 'DAYS', 'WEEKLY', 'MONTHLY', 'YEARLY';
numDaysToRotateRequired if 'DAYS' rotation type, with valid values between 2 and 14; otherwise, null;
resetAtUTC timestamp, in milliseconds, at which to rotate the period. Always null if 'NEVER' rotation type;
retainedCountRequired. Number of rotations (versions) of the leaderboard to retain;
expireInMinsOptional (but highly recommended). Duration, in minutes, before the leaderboard is to automatically expire. This ensures that the leaderboards are automatically cleaned up after the specified amount of time.

Usage

http://localhost:3000
string leaderboardId = "aLeaderboardId";
int score = 10;
string scoreData = "{\"nickname\": \"batman\"}";
string configJson = "{\"leaderboardType\": \"HIGH_VALUE\", \"rotationType\": \"DAYS\", \"numDaysToRotate\": 4, \"resetAt\": \"[[#ts+60000]]\", \"retainedCount\": 2, \"expireInMins\": \"None\"}";

SuccessCallback successCallback = (response, cbObject) =>
{
Debug.Log(string.Format("Success | {0}", response));
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
Debug.Log(string.Format("Failed | {0} {1} {2}", status, code, error));
};

_bc.LeaderboardService.PostScoreToDynamicLeaderboardUsingConfig(leaderboardId, score, scoreData, configJson, successCallback, failureCallback);
JSON Response
{
"status": 200,
"data": null
}