Skip to main content

Player

Player identification

On the Jest platform, each user has a unique playerId per game. This identifier remains the same if a player starts as a guest and later registers, allowing you to track player progress and store player data.

Guest users can be prompted to register or sign in on the Jest platform. See Platform login for more information.

Registered users can be re-engaged via notifications. See Notifications for more information.

Player.id

Returns the unique identifier for the current player.

var player = JestSDK.Instance.Player;
string playerId = player.id;

Player.isRegistered

Returns whether the current player is registered or playing as a guest.

var player = JestSDK.Instance.Player;

if (!player.isRegistered)
{
// Guest player: notifications cannot be scheduled
// Consider prompting the player to register
}
else
{
// Registered player: full functionality available
await JestSDK.Instance.RichNotifications.ScheduleNotification(new RichNotifications.Options
{
// ...
});
}

Player.GetSigned()

If your game has a backend, use this method to obtain a signed payload that can be sent to your server to authenticate the player and attach to authenticated requests.

This works for both registered players and guests. For guests, response.player.registered is false.

var player = JestSDK.Instance.Player;

var signedTask = player.GetSigned();
await signedTask;

if (signedTask.IsCompleted)
{
var response = signedTask.Result;
string playerId = response.player.playerId;
bool isRegistered = response.player.registered;
string signedPayload = response.playerSigned; // JWS format for server verification
}

The returned playerSigned value is a JSON Web Signature (JWS) signed using your game's shared secret with the HS-256 algorithm. You can use any standard JWS/JWT library on your backend to verify the signature and extract the player information.

The shared secret shown in the Developer Console is base64-encoded. Most JWT libraries expect the decoded key when verifying the signature.

The signed payload includes an issued-at (iat) timestamp that can be used to verify token freshness. Jest does not set an explicit expiration time; you may reject tokens older than a chosen threshold and have the client request a new token.

For server-side verification examples in various languages, see the HTML5 SDK Player documentation.

Player data

If your game does not have a backend, Jest provides a simple key-value store for per-player data.

Player data is stored alongside the player record on the Jest platform and is persistent across sessions and devices. All values must be serializable to JSON.

note

Player data is written directly from the game client and must not be used to store sensitive information or data that requires strong security guarantees.

note

Player data is limited to 1 MB per game; if this limit is exceeded, further writes will fail until the stored data size is reduced.

Player.Get<T>(key)

Retrieves and converts a value of the specified type associated with the given key.

var player = JestSDK.Instance.Player;

// Get primitive values
int level = player.Get<int>("level");
string nickname = player.Get<string>("nickname");

// Get custom struct
public struct PlayerStats
{
public int wins;
public int losses;
public float winRate;
}

PlayerStats stats = player.Get<PlayerStats>("stats");

Player.TryGet<T>(key, out value)

Attempts to retrieve and convert a value. Returns true if the key exists, false otherwise.

var player = JestSDK.Instance.Player;

if (player.TryGet<int>("coins", out int coins))
{
Debug.Log($"Player has {coins} coins");
}
else
{
Debug.Log("No coins data found");
}

Player.Set<T>(key, value)

Sets a value of the specified type for the given key.

var player = JestSDK.Instance.Player;

// Set primitive values
player.Set("level", 5);
player.Set("lastLogin", DateTime.Now);
player.Set("inventory", "sword");

// Set custom struct
player.Set("stats", new PlayerStats
{
wins = 10,
losses = 2,
winRate = 0.83f
});

Player.Delete(key)

Deletes the value associated with the specified key.

var player = JestSDK.Instance.Player;

player.Delete("temporaryBoost");

Player.Flush()

Flushes any pending player data changes to the server. The SDK batches multiple updates to reduce network requests; calling this method ensures all pending changes are sent immediately.

var player = JestSDK.Instance.Player;

// Update some data
player.Set("score", 1500);

// Flush pending changes before navigating away
// or when data must be persisted immediately
await player.Flush();
Debug.Log("All player data changes have been saved to the server.");