Skip to main content

Entry payload

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

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

  • Carrying over onboarding choices into the full app (for example, a chosen name or cosmetic option).
  • Tracking referral and invite details - specifically identifying who sent the invitation and for which feature. This allows apps to reward users for successful invitations. See Referrals and the Virality guide for more information.
  • Tracking which notification brought the player back to the app.

Read the entry payload

The SDK exposes the entry payload provided when the app was launched. If no payload was supplied, the result is empty.

JestSDK.getEntryPayload()

JestSDK.getEntryPayload(): { [key: string]: unknown };

Example:

await JestSDK.init();

const entryPayload = JestSDK.getEntryPayload();

const difficulty = entryPayload.difficulty ?? "normal";
const debugMode = entryPayload.mode === "debug";

console.log("Entry payload:", entryPayload);

Nested values

Entry payloads can contain nested objects.

Nested objects arrive as plain JavaScript objects. Values are typed unknown, so narrow them before use:

const entryPayload = JestSDK.getEntryPayload();

const referrer = entryPayload.referrer as { name?: string } | undefined;
if (referrer?.name) {
console.log(`Referred by: ${referrer.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
JestSDK.notifications.scheduleNotification({
body: "Your crops are ready!",
ctaText: "Harvest",
priority: "high",
identifier: "harvest_ready",
scheduledInDays: 1,
entryPayload: {
notification_type: "harvest_ready",
notification_day: "1",
},
});

// When the player returns via the notification
const entryPayload = JestSDK.getEntryPayload();
if (entryPayload.notification_type === "harvest_ready") {
// Show harvest UI immediately
showHarvestScreen();
}

Referral tracking

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

// When sharing
await JestSDK.referrals.shareReferralLink({
reference: "invite_friends",
entryPayload: {
referrer_id: JestSDK.getPlayer().playerId,
reward_type: "bonus_coins",
},
});

// When the invited player enters
const entryPayload = JestSDK.getEntryPayload();
if (entryPayload.referrer_id) {
console.log("Player was referred by:", entryPayload.referrer_id);
// 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.login({
entryPayload: {
source: "level_complete",
level: currentLevel,
},
});

// After login, retrieve the context
const entryPayload = JestSDK.getEntryPayload();
if (entryPayload.source === "level_complete") {
// Player just completed a level before registering
showLevelCompleteReward();
}

Test entry payload

You can test entry payload handling during development by passing an encoded payload via the URL:

npm run dev
open http://localhost:5173/?entryPayload=%7B%22difficulty%22:%22hard%22%7D