Class Tournaments
Contains functions and properties related to instant tournaments.
Inherited Members
Namespace: Meta.InstantGames
Assembly: Unity.Meta.InstantGames.Sdk.dll
Syntax
public class Tournaments : JsObject
Constructors
Tournaments()
Construct an instance of Tournaments
Declaration
public Tournaments()
Methods
CreateAsync(CreateTournamentPayload)
Opens the tournament creation dialog if the player is not currently in a tournament session.Exceptions: INVALID_PARAM, INVALID_OPERATION, DUPLICATE_POST, NETWORK_FAILURE
Declaration
public WebTask<Tournament> CreateAsync(CreateTournamentPayload payload)
Parameters
Type | Name | Description |
---|---|---|
Create |
payload | Tournament creation options |
Returns
Type | Description |
---|---|
Web |
A Web |
GetTournamentsAsync()
Returns a list of eligible tournaments that can be surfaced in-game, including tournaments 1) the player has created; 2) the player is participating in; 3) the player's friends (who granted permission) are participating in. The instant tournaments returned are active. An instant tournament is expired if its end time is in the past. For each instant tournament, there is only one unique context ID linked to it, and that ID doesn't change. Exceptions: NETWORK_FAILURE, INVALID_OPERATION
Declaration
public WebTask<Tournament[]> GetTournamentsAsync()
Returns
Type | Description |
---|---|
Web |
A Web |
JoinAsync(string)
Request a switch into a specific tournament context. If the player is not a participant of the tournament, or there are not any connected players participating in the tournament, this will reject. Otherwise, the promise will resolve when the game has switched into the specified context.Exceptions: INVALID_OPERATION, INVALID_PARAM, SAME_CONTEXT, NETWORK_FAILURE, USER_INPUT, TOURNAMENT_NOT_FOUND
Declaration
public WebTask JoinAsync(string tournamentID)
Parameters
Type | Name | Description |
---|---|---|
string | tournamentID | The Tournament ID of the desired context to switch into. |
Returns
Type | Description |
---|---|
Web |
A Web |
PostScoreAsync(double)
Posts a player's score to Facebook. This API should only be called within a tournament context at the end of an activity (example: when the player doesn't have "lives" to continue the game). This API will be rate-limited when called too frequently. Scores posted using this API should be consistent and comparable across game sessions. For example, if Player A achieves 200 points in a session, and Player B achieves 320 points in a session, those two scores should be generated from activities where the scores are fair to be compared and ranked against each other. Returns a promise that resolves when the score post is completed. Exceptions: INVALID_PARAM, TOURNAMENT_NOT_FOUND, NETWORK_FAILURE
Declaration
public WebTask PostScoreAsync(double score)
Parameters
Type | Name | Description |
---|---|---|
double | score | An integer value representing the player's score at the end of an activity. |
Returns
ShareAsync(ShareTournamentPayload)
Opens the reshare tournament dialog if the player is currently in a tournament sessionExceptions: INVALID_OPERATION, TOURNAMENT_NOT_FOUND, NETWORK_FAILURE
Declaration
public WebTask ShareAsync(ShareTournamentPayload payload)
Parameters
Type | Name | Description |
---|---|---|
Share |
payload | Specifies share content |