v24
Examples

User's score updated

1
var onUserScoreUpdated = function (newScore) {
2
record.score = newScore;
3
record.level = scoreToLevel(newScore);
4
leaderboard.setRecord(record, function() {}, function() {});
5
}
Copied!

User logged in with social network/SSO

1
var onUserLoggedinWithFacebook = function (fbUser) {
2
record.public_id = fbUser.id;
3
record.name = fbUser.name;
4
leaderboard.setRecord(record, function() {}, function() {});
5
}
Copied!

Display user's score

1
var success = function (response) {
2
displayRank(response.rank);
3
};
4
5
var failure = function () {
6
console.log("error:" + e.error);
7
};
8
9
var displayUsersRank = function () {
10
leaderboard.getRecord(record.user_private_id, success, failure);
11
}
Copied!
Last modified 2yr ago