Class Context
Contains functions and properties related to the current game context.
Inherited Members
Namespace: Meta.InstantGames
Assembly: Unity.Meta.InstantGames.Sdk.dll
Syntax
public class Context : JsObject
Constructors
Context()
Construct an instance of Context
Declaration
public Context()
Methods
ChooseAsync(ContextOptions)
Opens a context selection dialog for the player. If the player selects an available context, the client will attempt to switch into that context, and resolve if successful. Otherwise, if the player exits the menu or the client fails to switch into the new context, this function will reject. Exceptions: INVALID_PARAM, SAME_CONTEXT, NETWORK_FAILURE, USER_INPUT, PENDING_REQUEST, CLIENT_UNSUPPORTED_OPERATION
Declaration
public WebTask ChooseAsync(ContextOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
Context |
options | An object specifying conditions on the contexts that should be offered. |
Returns
Type | Description |
---|---|
Web |
A Web |
CreateAsync(string[])
Attempts to create a context between the current player and a specified player or a list of players. This API supports 3 use cases:1) When the input is a single playerID, it attempts to create or switch into a context between a specified player and the current player 2) When the input is a list of connected playerIDs, it attempts to create a context containing all the players 3) When there's no input, a friend picker will be loaded to ask the player to create a context with friends to play with For each of these cases, the returned Web
Declaration
public WebTask CreateAsync(string[] suggestedPlayerIds = null)
Parameters
Type | Name | Description |
---|---|---|
string[] | suggestedPlayerIds | A list of game suggested playerIDs or a single suggested playerID or no input |
Returns
Type | Description |
---|---|
Web |
A Web |
GetPlayersAsync()
Gets an array of Context
Declaration
public WebTask<ContextPlayer[]> GetPlayersAsync()
Returns
Type | Description |
---|---|
Web |
A Web |
SwitchAsync(string, bool)
Request a switch into a specific context. If the player does not have permission to enter that context, or if the player does not provide permission for the game to enter that context, this will reject. Otherwise, the promise will resolve when the game has switched into the specified context. Exceptions: INVALID_PARAM, SAME_CONTEXT, NETWORK_FAILURE, USER_INPUT, PENDING_REQUEST, CLIENT_UNSUPPORTED_OPERATION
Declaration
public WebTask SwitchAsync(string id, bool switchSilentlyIfSolo = false)
Parameters
Type | Name | Description |
---|---|---|
string | id | ID of the desired context or the string SOLO to switch into a solo context. |
bool | switchSilentlyIfSolo | If switching into a solo context, set this to true to switch silently, with no confirmation dialog or toast. This only has an effect when switching into a solo context. |