Skip to main content

Scheduled Notifications

Schedule a notification from the game: "Energy restored", "The building is ready", "Your chest is open". The notification comes when the player is not in the game.

List of Methods​

Actions:

Events:

info

Scheduling costs 1 request. Each delivered push additionally costs 2 requests, see limits and pricing.

How It Works​

  • Each scheduled notification has a tag. The player can have only one pending notification per tag.
  • Calling schedule() again with the same tag overwrites the pending notification: its content and its time. Pass keepTime: true to update only the content and keep the time.
  • The delay is from 60 seconds to 30 days.
  • A player can have no more than 16 pending tags at the same time.
  • You can use only templates with the Allow from players option (allowFromPlayers). See templates.
  • The notification is sent only if the player has a push channel and permission. Check gp.notifications.permission.
  • On MSN and Android, pass title and text, and the notification is scheduled on the device: no request to GamePush, no push limit spent. On Android this needs the cordova-plugin-local-notification plugin in the build. With only a template the notification is scheduled on the server and charged as usual (on MSN this needs the platform settings).

Schedule a Notification​

+1 Request
gp.notifications.schedule({
// Notification tag, required
tag: 'ENERGY_FULL',
// Template tag or ID, the template must allow use from players
template: 'ENERGY_FULL',
// In how many seconds to send
delay: 30 * 60,
// Template variables, optional
variables: { energy: 100 },
// Payload for the game when the player opens the notification, optional
payload: 'screen=play',
});

Instead of delay you can pass the exact time in ISO format:

gp.notifications.schedule({
tag: 'EVENT_START',
template: 'EVENT_START',
at: '2026-12-31T18:00:00Z',
});

Parameters:

ParameterTypeDescription
tagstringNotification tag. One pending notification per tag
templatestringTemplate tag or ID
delaynumberIn how many seconds to send, from 60 seconds to 30 days
atstringOr the exact send time, ISO 8601
variablesobjectTemplate variables, available as {variables.<key>} or {<key>}. More
payloadstringPayload for the game. If not passed, the template payload is used. More
keepTimebooleanIf a notification with this tag is already pending, update only its content and keep the time
titlestringTitle for a notification on the device (MSN, Android). Works together with text
textstringText for a notification on the device (MSN, Android). Works together with title

On MSN and Android you can schedule a notification on the device without a template:

gp.notifications.schedule({
tag: 'CHEST_OPEN',
title: 'The chest is open',
text: 'Come and see what is inside!',
delay: 4 * 60 * 60,
});

On other platforms title and text are ignored and the template is required.

The method returns the scheduled notification:

const notification = await gp.notifications.schedule({
tag: 'ENERGY_FULL',
template: 'ENERGY_FULL',
delay: 30 * 60,
});

// null if notifications are disabled in the project
if (!notification) {
return;
}

// ID
notification.id;
// Tag
notification.tag;
// Template
notification.template;
// Title and text in the player's language
notification.title;
notification.text;
// Payload
notification.payload;
// Send time, ISO 8601
notification.sendAt;
// Scheduled on the device (MSN, Android), without GamePush
notification.isLocal;
// Dev mode: simulated on the page, not sent to the server
notification.isDev;

Other errors reject the promise. See Notifications Disabled in the Project and error codes.

Subscribe to events:

// Notification scheduled
gp.notifications.on('schedule', (notification) => {
console.log('Scheduled at', notification.sendAt);
});

// Failed to schedule a notification
gp.notifications.on('error:schedule', (error, { input }) => {
// error - error code, input - schedule() parameters
console.warn('Failed to schedule', input.tag, error);
});

Overwriting and keepTime​

The notification with the same tag is overwritten. This is convenient for timers that change during the game.

// The player spent energy - move the "Energy restored" notification
myGame.on('energySpent', () => {
const secondsToFull = myGame.getSecondsToFullEnergy();

gp.notifications.schedule({
tag: 'ENERGY_FULL',
template: 'ENERGY_FULL',
delay: Math.max(60, secondsToFull),
});
});

With keepTime: true the time of a pending notification does not change, only the content is updated. If there is no pending notification with this tag, it is created with the passed time.

// Update the number of collected coins in the reminder, but do not move the time
gp.notifications.schedule({
tag: 'MINE_FULL',
template: 'MINE_FULL',
delay: 8 * 60 * 60,
variables: { coins: myGame.mineCoins },
keepTime: true,
});

Cancel a Notification​

+1 Request

Cancel the notification when it is no longer relevant. For example, the player has returned and collected the reward themselves.

gp.notifications.cancel({ tag: 'ENERGY_FULL' });
// Notification cancelled
gp.notifications.on('cancel', ({ tag }) => {});

// Failed to cancel a notification
gp.notifications.on('error:cancel', (error, { input }) => {});

Fetch Scheduled Notifications​

+1 Request
const notifications = await gp.notifications.fetchScheduled();

notifications.forEach((notification) => {
console.log(notification.tag, notification.sendAt);
});

Each item has the same fields as the result of schedule().

Example: Energy Restored​

const ENERGY_TAG = 'ENERGY_FULL';

function updateEnergyNotification() {
if (gp.notifications.permission !== 'granted') {
return;
}

const energy = gp.player.get('energy');
const maxEnergy = gp.player.get('energy:max');

// Energy is full - the notification is not needed
if (energy >= maxEnergy) {
gp.notifications.cancel({ tag: ENERGY_TAG });
return;
}

gp.notifications.schedule({
tag: ENERGY_TAG,
template: ENERGY_TAG,
delay: Math.max(60, myGame.getSecondsToFullEnergy()),
variables: { maxEnergy },
payload: 'screen=play',
});
}
tip

For energy based on a player field with auto-increment you do not need code at all: use the Player field reached max reminder.

Reminders Without Code​

Typical reminders are configured in the control panel, in the notification settings. GamePush tracks the time itself, you do not need to call schedule().

ReminderWhen it is sentSettings
Player field reached maxA player field with auto-increment has reached its maximum. For example, the energy is fullField key, template
Daily reward is availableThe reward of the day in the reward scheduler is waiting for the playerScheduler tag, template, hour in the player's local time
Daily rewards streak will be lostThe streak of consecutive days in the reward scheduler is about to burn outScheduler tag, template, how many hours before the end of the game day
Player has not entered for N daysThe player has not entered the game for N days (1–30). If the player comes back earlier, the reminder moves forward automaticallyNumber of days, template, hour in the player's local time

Add reminders in Notifications → Settings → Reminders. For the Player has not entered for N days reminder choose the number of days, the template and the hour; the panel warns which platforms send such reminders themselves.

Inactivity reminder settings

In reminder templates you can use these variables besides {player.name}:

VariableReminderValue
{scheduler.day} or {day}Daily reward, streakDay of the reward that waits for the player (after today's reward was claimed — the next one)
{scheduler.days} or {days}Daily reward, streakNumber of days in the scheduler
{days}Player has not entered for N daysN

{day} and {days} are also available as {variables.day} and {variables.days}, so one template works both for reminders and for gp.notifications.schedule() with variables: { day }.

When all days of the scheduler are claimed, its reminders are cancelled.

Inactivity reminders and platforms
  • VK sends notifications to inactive players itself (after 1, 7 and 30 days; the text is set in the VK game settings → Social mechanics → Notifications → «Inactive users»). GamePush does not send such reminders on VK so players do not get duplicates.
  • OK delivers notifications only to players who launched the game no more than 14 days ago, so on OK the reminder works for 1–14 days.
  • Web Push, Android, Telegram, MSN have no such platform feature — the reminder works for any number of days.

Stay in Touch​

Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.

GamePush Community Telegram: @gs_community.

For your suggestions e-mail: official@gamepush.com

We Wish you Success!