Skip to main content

Permissions and Delivery

How to ask the player for permission to receive notifications and how to handle the game launch from a notification.

List of Methods​

Actions:

Properties:

Events:

Check Availability​

FREE
// Wait until the SDK detects what the platform supports
await gp.notifications.ready;

// Can notifications be used right now
gp.notifications.isAvailable;

// Can the permission dialog be shown right now
gp.notifications.canRequest;

// Delivery channel: 'VK', 'OK', 'TELEGRAM', 'MSN', 'WEB_PUSH', 'FCM' or null
gp.notifications.channel;

// Notifications are enabled in the project settings
gp.notifications.isEnabled;
  • ready — the SDK detects the platform features in the background, and gp is ready earlier. If you check notifications right at the start, wait for ready first. For example, a game in an iframe on your site first asks the host page.
  • isAvailable takes everything into account: whether the platform has push notifications, whether they work in the current environment (for example, not in a regular Safari tab on iPhone) and whether notifications are enabled in the project. When isAvailable is false, use the inbox.
  • canRequest is false when the permission is already granted, the player has already declined it, or the platform does not allow asking right now. Show your soft ask only when canRequest is true.
  • channel is null when isAvailable is false because of the platform or environment.
  • isEnabled shows only the project setting. When notifications are disabled in the project, isAvailable and canRequest are false. See Notifications Disabled in the Project.

Supported Platforms​

  • ✅VK Games
  • ✅OK Games
  • ✅Telegram
  • ✅MSN
  • ✅Web (custom site)
  • ✅Google Play
  • ✅Android (alternative stores)
  • Platforms without support
  • ❌CrazyGames
  • ❌GamePix
  • ❌GameDistribution
  • ❌GameMonetize
  • ❌SmartMarket
  • ❌VK Play
  • ❌Yandex Games
  • ❌WG Playground
  • ❌Kongregate
  • ❌PlayDeck
  • ❌beeline
  • ❌Fotostrana
  • ❌Y8
  • ❌CoolMathGames
  • ❌Pikabu Games
  • ❌Partner's platforms
  • ❌Moi Mir
  • ChannelPlatformPlayer consentWhat you need to set up
    VKVK GamesVK "Allow notifications" dialogService key of the app in the VK platform settings
    OKOK GamesNo separate request, notifications are allowed by defaultPublic key and secret key of the app in the OK platform settings
    TelegramTelegramTelegram "Allow the bot to message you" dialogBot token (secret key) and game link in the Telegram platform settings
    MSNMSNMSN Games and browser permissionFor pushes from the server: Game ID and MS Start API Key in the MSN platform settings, otherwise delivery fails with msn_game_id_missing / msn_api_key_missing. Scheduling on the device with title and text needs nothing
    Web PushCustom sitesBrowser permission on your siteExternal SDK and service worker on your site
    FCMAndroid appsAndroid POST_NOTIFICATIONS permissiongoogle-services.json for the build and a Firebase service account
    info

    Some platforms do not support push notifications. On these platforms use the inbox: gp.notifications.isAvailable is false there, and campaigns with the Push and inbox or Inbox if no push channel delivery put messages into the inbox instead.

    Permission Status​

    FREE
    // 'granted' | 'denied' | 'default' | 'unknown'
    gp.notifications.permission;
    ValueMeaning
    'granted'The player allowed notifications
    'denied'The player declined notifications
    'default'The player has not been asked yet
    'unknown'The platform does not report the status

    Request Permission​

    FREE
    await gp.notifications.requestPermission();

    if (gp.notifications.permission === 'granted') {
    // The player will receive notifications
    }

    The SDK shows the platform's permission dialog and sends the result and the player's address (subscription, token) to GamePush. After that GamePush can deliver pushes to the player.

    caution

    Call requestPermission() only after a player action, for example a button click. Browsers block permission dialogs that are not caused by the player. Read the permission best practices.

    How the permission is requested on each platform:

    PlatformWhat happens
    VK GamesVK shows the "Allow notifications" dialog. If the player has already allowed notifications for the game, the status is 'granted' at startup
    OK GamesThere is no separate dialog, the permission is considered granted
    TelegramTelegram asks the player to allow the bot to send messages. If the player has already allowed it, the status is 'granted' at startup
    MSNThe permission is requested by MSN Games and the browser
    Custom sitesThe browser shows the dialog on the host page. Requires the Web Push setup
    AndroidAndroid shows the system POST_NOTIFICATIONS dialog (Android 13+)

    The method returns the permission status, the same as gp.notifications.permission:

    const permission = await gp.notifications.requestPermission();

    Subscribe to events:

    // Permission request finished: comes after every successful requestPermission() call,
    // even if the status has not changed
    gp.notifications.on('permission', (permission) => {
    console.log('Permission:', permission);
    });

    // Failed to request permission
    gp.notifications.on('error:permission', (error) => {
    console.warn('Failed to request permission', error);
    });

    If notifications are not available on the platform, requestPermission() is rejected with the notifications_not_available error. Other codes are listed in Errors.

    Service Worker Path​

    For Web Push on your own domain the SDK registers the service worker /gp-sw.js (see Web Push on Your Site). If the file is in another place, set the path in one of the ways:

    // Before the request
    gp.notifications.serviceWorkerPath = '/push/gp-sw.js';

    // Or right in the request
    gp.notifications.requestPermission({ serviceWorkerPath: '/push/gp-sw.js' });

    You can also pass the swPath parameter in the URL of the SDK script. An empty value resets the path to /gp-sw.js. When the game is in an iframe on your site, the path is set on the host page in sdk.notifications.init({ swPath }).

    Opening the Game from a Notification​

    FREE

    When the player taps a notification, the game starts and the SDK reads the notification data from the launch parameters. When notifications are enabled in the project, the SDK sends it with the first player sync: GamePush marks the notification as opened (opens are shown in statistics) and returns its payload in the same response — opening costs no extra request.

    // Payload of the notification from which the game was opened.
    // Empty if the game was not opened from a notification
    const payload = gp.notifications.launchPayload;

    if (payload) {
    myGame.handleNotification(payload);
    }

    The payload is a string. It comes from:

    The open event comes when a notification is opened while the SDK is running, for example a Web Push notification is clicked while the game tab is open:

    gp.notifications.on('open', ({ id, payload }) => {
    // id - notification ID
    // payload - payload of the notification
    myGame.handleNotification(payload);
    });

    Use the payload to open the right screen. For example, store JSON in the payload:

    gp.notifications.schedule({
    tag: 'BUILDING_READY',
    template: 'BUILDING_READY',
    delay: 2 * 60 * 60,
    payload: JSON.stringify({ screen: 'city', buildingId: 42 }),
    });

    And handle it on launch:

    function handleNotification(payload) {
    let data;
    try {
    data = JSON.parse(payload);
    } catch (err) {
    return;
    }

    if (data.screen === 'city') {
    myGame.openCity({ focusBuilding: data.buildingId });
    }
    }

    if (gp.notifications.launchPayload) {
    handleNotification(gp.notifications.launchPayload);
    }

    gp.notifications.on('open', ({ payload }) => handleNotification(payload));
    VK and OK

    VK and OK do not pass the payload into the game, so the SDK gets it from the server, and launchPayload works there too.

    • VK can pass a notification ID (ref_notification_id). GamePush uses it to find the exact push and its payload. When VK passes only a notification source, such as vk_ref=56 on desktop, GamePush uses the most recent unopened push delivered to this player in the project within the past 72 hours. If there is no matching push, the payload is empty.
    • OK does not pass the notification ID, only the launch source (vk_ok_ref, for example passive_simple_app_notification). The SDK detects a launch from a game notification and uses the payload of the last push delivered to the player. OK's own reminders («continue playing», recommendations) are not counted as opens.

    Telegram​

    In Telegram a notification arrives as a message from the bot with a Play button. The button opens the game and passes the notification ID and payload to it.

    The button appears only if the Link to the game on the platform field is filled in the Telegram platform settings. Without the link the bot sends text only: the player cannot open the game from the notification, and opens are not counted in the statistics.

    Set a direct link to the Mini App with the game:

    • https://t.me/<bot> if the game is the bot's main Mini App (the Open button in the bot profile);
    • https://t.me/<bot>/<short_name> if the game is a separate Mini App created with the /newapp command in @BotFather.

    GamePush adds the startapp parameter with the notification ID and payload to the link. If the payload does not fit into the link (startapp is limited to 512 characters), the SDK gets it from the server. The Mini App must belong to the same bot whose token is set in the platform settings.

    The button variable in the template variables sets the button text, for example { "button": "Claim the gift" }. Without the variable the button says "Play" in the player's language.

    tip

    Keep the payload short. Platforms limit the length of the launch link.

    Delivery​

    • GamePush delivers pushes only to players who have a push channel and gave permission.
    • For VK, OK, Telegram and MSN the player's channel is registered automatically when the player enters the game. For Web Push and Android, the channel is registered after requestPermission().
    • Each push is delivered through one channel per player, chosen by priority: the platform channel (VK, OK or MSN) → Telegram → FCM → Web Push.
    • You can see the delivery log of a player and the reason for each skipped notification in the control panel.

    Quiet Hours​

    • A push that falls into quiet hours is postponed until the quiet hours end.
    • Quiet hours are calculated in the player's time zone. On VK and OK, if the player's time zone is unknown, Moscow time is used; on other platforms — UTC.
    • Personal notifications that would be delayed by more than 24 hours are skipped.
    • Test pushes ignore quiet hours.

    Skipped Notifications​

    A push is skipped — not sent and not charged — if:

    • the player is online (for personal notifications, with the Skip if online option);
    • the player has returned to the game (for Inactivity campaigns);
    • the daily limit per player or platform limits are exceeded;
    • the monthly limit of your plan is reached.

    Only delivered pushes are charged: skipped notifications and failed deliveries are not billed.

    Testing during development​

    In dev mode (gp.isDev: the game is opened from an origin marked as test in the project settings) notifications are simulated in the devtools overlay instead of real delivery — the same way payments and ads are emulated. No separate test methods are needed: call the regular API.

    // in dev mode it is not sent to the server:
    // the template is rendered for the current player and the notification appears on the page in 60 seconds
    gp.notifications.schedule({
    tag: 'ENERGY_FULL',
    template: 'energy_full',
    delay: 60,
    payload: 'screen=shop',
    });
    • At the planned time the notification appears at the top center of the page, like on a phone. Several notifications stack: tap the stack to expand it, scroll and tap the one you need.
    Dev notification banner Expanded stack of dev notifications
    • The card shows the template icon, the rendered title and text, and the payload.
    • Open — the game receives the open event (as if the notification was tapped while the game is running).
    • Open with restart — the page restarts with gp_n / gp_payload, the full launch path: check launchPayload / launchId on start.
    • Dev notifications have isTest: true and IDs starting with dev:; they are not counted in statistics and are not charged.
    • Pending dev notifications are listed in the devtools panel (Notifications block) with a Deliver now button — no need to wait for the delay. They are kept in the browser, so a page reload does not lose them, like real notifications while the game is closed.
    Pending dev notifications in the devtools panel
    • Template checks are the same as in production: the template must exist and have Allow using the template from SDK enabled.

    The overlay only emulates delivery: real delivery through VK, OK, Telegram, Web Push and FCM is done by GamePush. To see how a template will look for the current player, use gp.notifications.preview(); for several players of the audience, use the campaign send preview in the control panel.

    For QA all methods (permission, scheduled notifications, preview, inbox, chat with notificationOptions) are collected on the Notifications page of the GamePush Sandbox.

    Preview a Notification​

    FREE

    Check a template before you send it: the text in the player's language with the variables filled in, how the platform will show it, and which variables are empty. Nothing is sent, and the request is free.

    const preview = await gp.notifications.preview({
    template: 'ENERGY_FULL',
    variables: { energy: 100 },
    });

    if (preview.missingVariables.length) {
    console.warn('Empty variables:', preview.missingVariables);
    }

    Without a template, pass your own title and text:

    const preview = await gp.notifications.preview({
    title: 'Energy is full',
    text: '{player.name|Hero}, time to play!',
    });

    Parameters:

    ParameterTypeDescription
    templatestringTemplate tag or ID. If not passed, title and text are used
    titlestringTitle without a template
    textstringText without a template
    variablesobjectTemplate variables. More
    payloadstringPayload. If not passed, the template payload is used

    Result:

    FieldTypeDescription
    playerIdnumberPlayer ID
    playerNamestringPlayer name
    platformstringPlayer platform
    channelstring | nullDelivery channel. null — the player has no push channel, only the inbox
    langstringLanguage of the text
    titlestringTitle with variables
    textstringText with variables
    displayTitlestringTitle as the platform shows it. VK and OK show one line «title — text»
    displayTextstringText as the platform shows it
    truncatedbooleanThe text is cut to the platform limit
    iconstringIcon
    imagestringImage
    payloadstringPayload
    missingVariablesstring[]Variables without a value and without a default

    If the template is not found, the promise is rejected with the notification_template_not_found error.

    Notifications Disabled in the Project​

    When notifications are disabled in the project settings, or the account plan is below Start, the game code keeps working without errors (test players are not affected: for them notifications always work):

    • isAvailable and canRequest are false.
    • requestPermission() does not show the dialog and resolves with the current status.
    • Player contacts are not saved. After you enable notifications (or upgrade the plan), the SDK registers the contact on the player's next launch.
    • The SDK sends no notification requests on start and does not check the platform. A launch from a notification is not processed: the open event does not fire, but launchPayload and launchId are still read from the launch parameters.
    • schedule() resolves with null and fires error:schedule with the notifications_disabled error. Check the result before reading its fields:
    const notification = await gp.notifications.schedule({
    tag: 'ENERGY_FULL',
    template: 'ENERGY_FULL',
    delay: 30 * 60,
    });

    if (notification) {
    console.log('Scheduled at', notification.sendAt);
    }

    Errors​

    Error codes of gp.notifications. They come in the rejected promise and in the error:* events.

    ErrorWhat it means
    notifications_not_availableNotifications are not available on this platform or in this environment. Check isAvailable
    notifications_disabledNotifications are disabled in the project settings
    wrong_tagtag is not passed in schedule() or cancel(), or it starts with the reserved reminder:, chat: or inactivity:
    wrong_timeNeither delay nor at is passed, delay is negative or at is not a date
    notification_template_not_foundThe template is not found. In schedule() also when the template is not passed and the notification is not scheduled on the device
    notification_template_not_allowed_from_playersThe template does not have the Allow from players option
    notification_bad_delayThe send time is earlier than in 60 seconds or later than in 30 days, or at is not in the 2026-12-31T18:00:00Z format
    notification_too_many_pendingThe player already has 16 pending tags
    vapid_key_missingWeb Push: the SDK did not get the VAPID key of the project
    host_not_respondingWeb Push in an iframe: the host page with the external SDK did not respond in time

    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!