Examples

User's score updated

var onUserScoreUpdated = function (newScore) {
record.score = newScore;
record.level = scoreToLevel(newScore);
leaderboard.setRecord(record, function() {}, function() {});
}

User logged in with social network/SSO

var onUserLoggedinWithFacebook = function (fbUser) {
record.public_id = fbUser.id;
record.name = fbUser.name;
leaderboard.setRecord(record, function() {}, function() {});
}

Display user's score

var success = function (response) {
displayRank(response.rank);
};
var failure = function () {
console.log("error:" + e.error);
};
var displayUsersRank = function () {
leaderboard.getRecord(record.user_private_id, success, failure);
}