Skip to main content

Entry payload

Games can be launched with an entry payload attached to the link used to enter the game. The entry payload is arbitrary metadata that is made available to the game on startup.

Entry payloads enable a range of use cases, such as:

  • Carrying over onboarding choices into the full game (for example, a chosen name or cosmetic option).
  • Encoding referral or invite information, such as which player sent an invite and for which feature. This allows games to reward players for successful invitations.
  • Tracking which notification brought the player back to the game.

JestSDK.Instance.GetEntryPayload()

Returns the entry payload provided when the game was launched, or an empty dictionary if no payload was supplied.

var jest = JestSDK.Instance;
var entryPayload = jest.GetEntryPayload();

if (entryPayload.TryGetValue("difficulty", out var difficulty))
{
Debug.Log($"Starting with difficulty: {difficulty}");
}

if (entryPayload.TryGetValue("mode", out var mode) && mode.ToString() == "debug")
{
EnableDebugMode();
}

Working with nested objects

Entry payloads can contain nested objects. When accessing nested data, you may need to cast or deserialize the values:

var entryPayload = JestSDK.Instance.GetEntryPayload();

// Access nested referrer data
if (entryPayload.TryGetValue("referrer", out var referrerObj))
{
var referrer = referrerObj as Dictionary<string, object>;
if (referrer != null && referrer.TryGetValue("name", out var name))
{
Debug.Log($"Referred by: {name}");
}
}

Common use cases

Notification attribution

When scheduling notifications, you can attach entry payload data that will be passed back when the player opens the notification:

// When scheduling
await JestSDK.Instance.RichNotifications.ScheduleNotification(new RichNotifications.Options
{
body = "Your crops are ready!",
ctaText = "Harvest",
identifier = "harvest_ready",
scheduledInDays = 1,
entryPayloadData = new Dictionary<string, object>
{
{ "notification_type", "harvest_ready" },
{ "notification_day", 1 }
}
});

// When the player returns via the notification
var entryPayload = JestSDK.Instance.GetEntryPayload();
if (entryPayload.TryGetValue("notification_type", out var notifType))
{
if (notifType.ToString() == "harvest_ready")
{
// Show harvest UI immediately
ShowHarvestScreen();
}
}

Referral tracking

When sharing referral links, the entry payload carries referrer information:

// When sharing
await JestSDK.Instance.Referrals.OpenReferralDialog(new Referrals.OpenDialogOptions
{
reference = "invite_friends",
entryPayload = new Dictionary<string, object>
{
{ "referrer_id", JestSDK.Instance.Player.id },
{ "reward_type", "bonus_coins" }
}
});

// When the invited player enters
var entryPayload = JestSDK.Instance.GetEntryPayload();
if (entryPayload.TryGetValue("referrer_id", out var referrerId))
{
Debug.Log($"Player was referred by: {referrerId}");
// Show welcome message or apply bonuses
}

Login with context

When prompting login, you can pass context that will be available after the player registers:

// Prompt login with context
JestSDK.Instance.Login(new Dictionary<string, object>
{
{ "source", "level_complete" },
{ "level", currentLevel }
});

// After login, retrieve the context
var entryPayload = JestSDK.Instance.GetEntryPayload();
if (entryPayload.TryGetValue("source", out var source) && source.ToString() == "level_complete")
{
// Player just completed a level before registering
ShowLevelCompleteReward();
}