docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Player

    Contains functions and properties related to the current player.

    Inheritance
    object
    JsObject
    Player
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Meta.InstantGames.v8
    Assembly: Unity.Meta.InstantGames.Sdk.v8.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
    WebTask<bool>

    A WebTask<T> indicating whether a player can subscribe to the game bot or not. Developer can only call subscribeBotAsync() after checking canSubscribeBotAsync(), and the game will only be able to show the player their bot subscription dialog once per week.

    GetASIDAsync()

    A unique identifier for the player. This is the standard Facebook Application-Scoped ID which is used for all Graph API calls. If your game shares an AppID with a native game this is the ID you will see in the native game too.

    Declaration
    public WebTask<string> GetASIDAsync()
    Returns
    Type Description
    WebTask<string>

    A unique identifier for the player.

    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
    WebTask<ConnectedPlayer[]>

    A WebTask<T> that resolves with a list of ConnectedPlayer. NOTE: This function should not be called until FBInstant.initializeAsync() has resolved.

    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
    WebTask<string>

    A WebTask<T> that resolves with an object which contains the current key-value pairs for each key specified in the input array, if they exist.

    GetID()

    A unique identifier for the player. A Facebook user's player ID will remain constant for a game, and is scoped to a specific game. This means that different games will have different player IDs for the same user. This function should not be called until FBInstant.initializeAsync() has resolved.

    Declaration
    public string GetID()
    Returns
    Type Description
    string

    A unique identifier for the player.

    GetSignedASIDAsync()

    Fetch the player's Application-Scoped ID 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.

    Declaration
    public WebTask<SignedASID> GetSignedASIDAsync()
    Returns
    Type Description
    WebTask<SignedASID>

    A WebTask<T> that resolves with a SignedASID object.

    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
    WebTask<SignedPlayerInfo>

    A WebTask<T> that resolves with a SignedPlayerInfo object.

    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
    WebTask

    A WebTask that resolves when the input values are set. NOTE: The promise resolving does not necessarily mean that the input has already been persisted. Rather, it means that the data was valid and has been scheduled to be saved. It also guarantees that all values that were set are now available in player.getDataAsync.

    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()
    Returns
    Type Description
    WebTask

    A WebTask that resolves if player successfully subscribed to the game bot, or rejects if request failed or player chose to not subscribe.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)