PlayPortalLeaderboardClient

This class is responsible for making requests to the playPORTAL leaderboard API.
public sealed class PlayPortalLeaderboardClient

While playPORTAL buckets allow your app to store private data for a single user, or share data between multiple users, leaderboards allow you to create and share scores between all users of your app. Leaderboard scores will be returned sorted, allowing you to create high score leaderboards visible to all users of your app. You can also create leaderboard entries with a "category" tag, allowing you to create multiple distinct leaderboards for your app.

You will need to enable the "Leaderboard" scope for your app in the developer dashboard before using the leaderboard API.

Properties

public static readonly PlayPortalLeaderboardClient Instance

Singleton instance of PlayPortalLeaderboardClient. You will access all the available PlayPortalLeaderboardClient methods through this instance.

Methods

GetLeaderboardEntries

public void GetLeaderboardEntries(Action<Exception, List<PlayPortalLeaderboardEntry>> completion, List<string> categories = null, int? page = null, int? limit = null)

Get all leaderboard entries for your app or filter out leaderboard entries by supplying one or more category tags. Supports pagination through the page and limit parameters.

Parameter

Type

Description

completion

Action<Exception, List<PlayPortalLeaderboardEntry>>

The delegate invoked when the request finishes. Called with an Exception argument if the request fails; otherwise, called with a List of PlayPortalLeaderboardEntry.

categories

List<string>

Filter leaderboard entries by specifying what entries to return based on their category tags. An empty List will return all entries.

page

int?

At what page to return leaderboard entries, where page length is determined by limit.

limit

int?

The maximum number of leaderboard entries to return.

GetUserRank

public void GetUserRank(Action<Exception, PlayPortalLeaderboardEntry> completion, string userId = null, List<string> categories = null)

Request a user's leaderboard entry. If userId is not supplied, will return the leaderboard entry for the currently authenticated user.

Parameter

Type

Description

completion

Action<Exception, PlayPortalLeaderboardEntry>

The delegate invoked when the request finishes. Called with an Exception argument if the request fails; otherwise, called with an instance of PlayPortalLeaderboardEntry.

userId

string

User whose leaderboard entry will be returned. If null, will return the leaderboard entry for the currently authenticated user.

categories

List<string>

Filter what entry to return by specifying category tags.

UpdateLeaderboard

public void UpdateLeaderboard(double score, Action<Exception, PlayPortalLeaderboardEntry> completion, List<string> categories = null)

Add a leaderboard entry. Entries are simply represented by a score (Double) and can be created with zero or more category tags. If a leaderboard entry already exists with the same categories, an upsert will be performed, rather than creating a new entry.

Parameter

Type

Description

score

double

The score being added.

completion

Action<Exception, PlayPortalLeaderboardEntry>

The delegate invoked when the request finishes. Call with an Exception argument if the request fails; otherwise, called with an instance of PlayPortalLeaderboardEntry representing the newly created or updated entry.

categories

List<string>

List of categories to tag the entry with.