Class Player
Contains functions and properties related to the current player.
Inherited Members
Namespace: Meta.InstantGames
Assembly: Unity.Meta.InstantGames.Sdk.dll
Syntax
public class Player : JsObject
Constructors
Player()
Construct an instance of Player
Declaration
public Player()
Methods
CanSubscribeBotAsync()
Returns a promise that resolves with whether the player can subscribe to the game bot or not. Exceptions: RATE_LIMITED, CLIENT_UNSUPPORTED_OPERATION, INVALID_OPERATION
Declaration
public WebTask<bool> CanSubscribeBotAsync()
Returns
Type | Description |
---|---|
Web |
A Web |
GetConnectedPlayersAsync()
Fetches an array of ConnectedPlayer objects containing information about active players (people who played the game in the last 90 days) that are connected to the current player.Exceptions: NETWORK_FAILURE, CLIENT_UNSUPPORTED_OPERATION
Declaration
public WebTask<ConnectedPlayer[]> GetConnectedPlayersAsync()
Returns
Type | Description |
---|---|
Web |
A Web |
GetDataAsync(string[])
Retrieve data from the designated cloud storage of the current player. Please note that JSON objects stored as string values would be returned back as JSON objects. Returns a promise that resolves with an object which contains the current key-value pairs for each key specified in the input array, if they exist. Exceptions: INVALID_PARAM, NETWORK_FAILURE, CLIENT_UNSUPPORTED_OPERATION
Declaration
public WebTask<string> GetDataAsync(string[] keys)
Parameters
Type | Name | Description |
---|---|---|
string[] | keys | An array of unique keys to retrieve data for |
Returns
Type | Description |
---|---|
Web |
A Web |
GetName()
The player's localized display name. This function should not be called until FBInstant.initializeAsync() has resolved.
Declaration
public string GetName()
Returns
Type | Description |
---|---|
string | The player's display name. |
GetPhoto()
A url to the player's public profile photo. The photo will always be a square, and with dimensions of at least 200x200. When rendering it in the game, the exact dimensions should never be assumed to be constant. It's recommended to always scale the image to a desired size before rendering. The value will always be null until FBInstant.initializeAsync() resolves. WARNING: Due to CORS, using these photos in the game canvas can cause it to be tainted, which will prevent the canvas data from being extracted. To prevent this, set the cross-origin attribute of the images you use to 'anonymous'.
Declaration
public string GetPhoto()
Returns
Type | Description |
---|---|
string | A url to the player's public profile photo. |
GetSignedPlayerInfoAsync()
Fetch the player's unique identifier along with a signature that verifies that the identifier indeed comes from Facebook without being tampered with. This function should not be called until FBInstant.initializeAsync() has resolved.Exceptions: NETWORK_FAILURE, CLIENT_UNSUPPORTED_OPERATION, INVALID_PARAM
Declaration
public WebTask<SignedPlayerInfo> GetSignedPlayerInfoAsync()
Returns
Type | Description |
---|---|
Web |
A Web |
SetDataAsync(string)
Set data to be saved to the designated cloud storage of the current player. The game can store up to 1MB of data for each unique player.Exceptions: INVALID_PARAM, NETWORK_FAILURE, PENDING_REQUEST, CLIENT_UNSUPPORTED_OPERATION
Declaration
public WebTask SetDataAsync(string data)
Parameters
Type | Name | Description |
---|---|---|
string | data | An object containing a set of key-value pairs that should be persisted to cloud storage. The object must contain only serializable values - any non-serializable values will cause the entire modification to be rejected. |
Returns
Type | Description |
---|---|
Web |
A Web |
SubscribeBotAsync()
Request that the player subscribe the bot associated to the game. The API will reject if the subscription fails - else, the player will subscribe the game bot. Exceptions: INVALID_PARAM, CLIENT_REQUIRES_UPDATE, PENDING_REQUEST
Declaration
public WebTask SubscribeBotAsync()