Push notifications in Yandex Cloud Notification Service
Push notifications are pop-up messages on your smartphone screen with information about Yandex Cloud Notification Service events, its services, promotions, news, and updates.
Push notifications are sent via mobile platform notification services:
- Apple Push Notification service
(APNs). - Firebase Cloud Messaging
(FCM). - Huawei Mobile Services
(HMS). - RuStore
.
Note
The service is subject to limitations. For more information, see Yandex Cloud Notification Service quotas and limits.
Push notification delivery algorithm using FCM as an example:
- In CNS, you create a mobile push notification channel for a specific platform (FCM) and your app.
- FCM maintains a persistent network connection with all registered mobile devices to deliver push notifications to apps on those devices.
- Your app on a particular device registers in FCM and receives a unique token to send push notifications to that device.
- The token is stored in CNS as a parameter of the application's mobile endpoint.
- To send a notification, you publish a message in CNS and specify the endpoint ID (ARN) as the recipient.
Mobile push notification channel
Mobile push notification channel is a tool for message delivery via a notification service. Notification channels correspond to platforms where you can send push notifications.
Channel names are unique within the entire CNS. You cannot create a channel with a name that is already taken. Once you create a channel, you cannot change its name.
The minimum information you need to create a channel depends on the platform and may include:
- Key or key ID, token, or certificate.
- Developer, application, or project ID.
For the full list of details required for each notification channel, see Creating a push notification channel. You can get your authentication parameters in the developer console of the relevant mobile platform.
Once you create a notification channel, it gets a unique ID (ARN).
Mobile endpoints
Each channel has its own base of mobile endpoints to send notifications directly to the app on user devices.
A mobile endpoint contains information about a token to send push notifications to a specific device and notification channel ID (ARN).
Token lifetime
Push notification tokens have a limited lifetime that depends on a specific platform, user actions, and other factors.
CNS gets feedback from each platform when sending notifications and uses it to manage tokens. If a token is out of date, CNS will delete the endpoint.
Recommended algorithm for working with tokens using a mobile app:
- The app registers in the mobile notification service, e.g., APNs, and receives a token to send push notifications.
- The app provides the token to CNS, gets the endpoint ID (ARN), and stores it on the device.
- Each time the app is launched, it registers again in the mobile notification service, e.g., APNs, and checks to see if the token has changed.
- If the token has changed, the app provides the new token and the endpoint ID (ARN) to CNS. If such an endpoint ID (ARN) does not already exist for some reason, a new endpoint is created in CNS and stored in the app.
Tip
We do not recommend overwriting the token in the endpoint each time the app is launched. If the token has not changed, in some cases this may result in lost notifications.