One-time notifications

One-time notifications are sent to a user when a certain event occurs in the game. For example, at the start of a campaign or a contest among players, when bonuses are granted, or when a goal is achieved. These notifications are also called situational notifications.

To send one-time notifications, use the VK API. In Odnoklassniki, you can also set up user notifications. For more details, see Notifications in Odnoklassniki.

Limitations

  • Notifications can be used in a game only after it has passed moderation and has been published in the catalog. Unpublished games can send notifications only to their administrators.
  • A user can receive only 1 notification per hour and no more than 3 per day.
  • You can't send two consecutive notifications with the same text to the same user.
  • To create notifications, the game status must be Enabled.

Notification permission

By default, the game can send notifications to users. If the user has denied notifications, you can request permission again using a VK Bridge event.

Requesting permission

To request a user's permission to send notifications from your game, call the VKWebAppAllowNotifications event.

Information about the notification permission status is also passed at game launch in the vk_are_notifications_enabled launch parameter. Use this parameter to determine whether you need to request the user's permission.

The user must have notifications from games and apps enabled in their VK settings. Otherwise, they won't receive notifications even if the game has permission to send them.

Checking permission

Users can manage notifications in their VK settings, so it's important to check whether notifications can be sent, even if they haven't enabled or disabled them directly in your game. To do this, use the apps.isNotificationsAllowed method with the game’s service access token.

Important! The method with the service access token can be called only from the server.

Example of calling the apps.isNotificationsAllowed method using a POST request.

Bash
curl -X POST 'https://api.vk.ru/method/apps.isNotificationsAllowed' \ -H 'Authorization: Bearer <ACCESS_TOKEN>' \ -F 'user_id=<USER_ID>' \ -F 'apps_id=<GAME_ID>' \ -F 'v=<API_VERSION>'

How to send a notification

To send a one-time notification, make the secure.sendNotification API request from your game’s server side. Use the service access token from the game settings to send the request.

Important! The method uses the service access token and can be called only from the server.

The request parameters include the message text and the IDs of one or more users who will receive the notification.

Using the vk_ref launch parameter, you can track where the game was launched from and measure notification conversion and performance.

Related materials