Skip to main content
info
Universal Push SDK is developed by VK and is not a RuStore product. RuStore recommends using this SDK to work with push notifications in your apps.

Push Notification API: Working with RuStore, FCM, and HMS

The API is designed to provide the ability to send push notifications by topic through multiple push providers simultaneously.

To send a push notification, use the POST method at https://vkpns-universal.rustore.ru/v1/send/topic.

To send a push notification to a topic, you must specify the Project ID and Authorization Token for each provider through which you plan to send push notifications.

Use project_id (Project ID) and ss_token (service token). You can obtain these values in the RuStore Console system. To do this, go to the Push Notifications section on the app page and select Projects. Sending Push Notifications.

Request Body​

ParameterTypeRequiredDescription
providersobject (providers)yesProviders for sending push notifications.
topicstringyesTopic name.
messageobject (message)yesPush notification structure.

providers​

ParameterTypeRequiredDescription
rustoreobject (provider)noRuStore provider.
fcmobject (provider)noFirebase provider.
hmsobject (provider)noHuawei provider.

providers.provider​

ParameterTypeRequiredDescription
project_idstringyesProject ID.
auth_tokenstringyesAuthorization token.

message​

ParameterTypeRequiredDescription
datamapnoAn object containing "key": value pairs.
notificationobject (message.notification)yesBasic notification template for use on all platforms.
androidobject (message.android)HMS onlyAndroid-specific parameters for messages.

message.notification​

ParameterTypeRequiredDescription
titlestringyesNotification title.
bodystringyesNotification body text.
imagestringnoContains a URL to an image to be displayed in the notification.

message.android​

ParameterTypeRequiredDescription
ttlstring (duration format)noHow long (in seconds) the message should be stored.
Example: 3.5s.
notificationobject (message.android.notification)HMS onlyNotification for sending to Android devices.

message.android.notification​

ParameterTypeRequiredDescription
titlestringyesNotification title.
bodystringyesNotification body text.
iconstringnoNotification icon.
colorstringnoNotification icon color in #rrggbb format.
imagestringnoContains a URL to an image to be displayed in the notification.
channel_idstringnoNotification channel ID.
click_actionstringnoAction associated with the user clicking the notification.
In HMS, the default type is 1 (intent).
info

Only the fields listed above are supported in the message structure.

Successful Response Body​

ParameterTypeDescription
statusstringOn successful response, returns a message with status OK.

Error Body​

ParameterTypeDescription
codenumberNumeric error code (404, 400, 403, 401, ...).
statusstringGeneral error description.
errorsarray (string)Provider-specific errors or validation errors.

HTTP status corresponds to the code field.

Errors are divided into three types

  • Message validation errors.
  • Provider sending errors.
  • Service errors.

Possible errors when sending a message

  • VALIDATION_ERROR — incorrectly specified request parameters when sending a message.
  • PROVIDER_ERROR — error sending to the push provider.
  • INTERNAL_ERROR — internal service error.

Possible validation errors when sending a message

  • providers.%provider_name% — error in the provider.
  • message.%field% — error in the message.

Possible provider errors when sending a message, in the format %provider_name%: %error%

  • internal — internal provider error.
  • validation error — validation error on the provider side.
  • invalid auth token — auth token error.
  • too many requests — too many requests.

Validation Algorithm​

A provider must have tokens.

providers​

At least one provider must be specified; without providers, the request is invalid.

message​

  • If there is a non-empty payload message.data (i.e., at least one key-value pair inside), the message is valid. The message.notification and message.android sections may be absent.
  • If the message.data field is absent, notification must be present. In this case, either message.notification or message.android.notification must be present. At least one of these fields must be present, but both may be present (if both are present, some fields are overwritten).

Limitations​

  • If the notification does not have a ttl field or it equals 0, the default value of 4 weeks is used. If the message.android section is absent, it is added with the ttl field.
  • Maximum message size is 4096 bytes.