The translation was generated automatically and may contain mistakes
Non-recurrent notifications
The mini-app can send one-time notifications to the user when an event occurs, such as a promotion, a contest among players, the issuance of bonuses or the achievement of a goal. Such notifications are also called situational.
The VKontakte API is used to send one-time notifications.
Restrictions
- •The user can send 1 notification per hour and no more than 3 notifications per day.
- •One user cannot send two consecutive notifications with the same text.
- •Notifications can be sent to a mini-app that has passed moderation . At the same time, placement in the catalog is not necessary.
- •Users may receive notifications only after issuance of authorization .
Authorization of notifications
You can send notifications to users from the mini-app only after receiving permission from the user.
Request for permission
To request user permission to send notifications from the mini-app, call the event VKWebAppAllowNotifications .
Notification connection status information is also transmitted when the application is launched to start Parameter vk_are_notifications_enabled . Use this option to determine if you need to request permission from the user.
The user should have notifications from games and applications enabled in the VKontakte settings. Otherwise, the user will not receive a notification, even if you have given permission in your application.
Permission verification
The user can manage notifications from the VKontakte settings, so it is important to check the ability to send, even if he did not disable or enable notifications directly from your mini-app. Use this method apps.isNotificationsAllowed c service key of access Mini-applications.
Important! Method C service key of access It can only be called on the server.
Example method call apps.isNotificationsAllowed with a POST request.
curl -X POST 'https://api.vk.ru/method/apps.isNotificationsAllowed' \
-H 'Authorization: Bearer <КЛЮЧ_ДОСТУПА>' \
-F 'user_id=<ИДЕНТИФИКАТОР_ПОЛЬЗО?1?’АТЕЛЯ>' \
-F 'apps_id=<ИДЕНТИФИКАТОР_МИНИ_ПРИЛОЖЕНИЯ>' \
-F 'v=<?1?’ЕРСИЯ_API>'How to send a notification
Use the method notifications.sendMessage c service key of access Mini-applications.
If your mini-application has hash navigation implemented, you can redirect the user directly from the notification using the parameter fragment . It will return with the launch parameters after the character # .
Important! Method C service key of access It can only be called on the server.
Example method call notifications.sendMessage with a POST request.
curl -X POST 'https://api.vk.ru/method/notifications.sendMessage' \
-H 'Authorization: Bearer <КЛЮЧ_ДОСТУПА>' \
-F 'user_ids=<ИДЕНТИФИКАТОРЫ_ПОЛЬЗО?1?’АТЕЛЕЙ>' \
-F 'message=<ТЕКСТ_У?1?’ЕДОМЛЕНИЯ>' \
-F 'fragment=<СОДЕРЖИМОЕ_ХЕША>' \
-F 'v=<?1?’ЕРСИЯ_API>'Disabling notifications
To disable sending notifications from the mini-app to the user, call the event VKWebAppDenyNotifications .
Materials on the topic
- •
- •
- •
- •
- •