Getting started with push notifications in Yandex Cloud Notification Service
Note
The service is at the preview stage.
To enable Cloud Notification Service, request access to the service from your account manager or technical support
Cloud Notification Service (CNS) is a service for multichannel notifications of users. The service's HTTP API is compatible with the Amazon SNS API
With Cloud Notification Service, you can send push notifications to apps registered in the following services:
- Apple Push Notification service
(APNs). - Firebase Cloud Messaging
(FCM). - Huawei Mobile Services
(HMS).
Push notifications via RuStore
To get started with push notifications:
Prepare your cloud
Sign up for Yandex Cloud and create a billing account:
- Go to the management console
and log in to Yandex Cloud or create an account if you do not have one yet. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVE
orTRIAL_ACTIVE
status. If you do not have a billing account, create one.
If you have an active billing account, you can go to the cloud page
Learn more about clouds and folders.
Create a push notification channel
In Cloud Notification Service, messages to end users are sent through notification channels.
To create a channel:
-
In the management console
, select the folder you want to create a notification channel in. -
In the list of services, select Cloud Notification Service.
-
Click Create notification channel.
-
Select a sending platform in the Mobile push notifications tab:
Apple iOS
: For iOS devices.Google Android
: For Android devices with Google Play services installed.Huawei Android
: For Android devices with Huawei services installed.
-
Depending on the platform you select, set the authentication parameters:
Apple iOS
-
Select the Authentication method:
Token
orCertificate
.You can authenticate with APNs using either a token or a certificate:
-
To authenticate using a token, you will need the following data:
-
Signature key: File with the signature key that you will use to certify the authentication token.
Create and download a signature key in your Apple developer account: Certificates, Identifiers & Profiles → Keys →
. You can download the key file only once. -
Key ID (Key ID): Get the ID in your Apple developer account: Certificates, Identifiers & Profiles → Keys. Make sure the ID matches the signature key you downloaded in the previous step. It must be 10 characters long.
-
Developer ID (Team ID): You can find it in the top-right corner of your Apple developer account. It must be 10 characters long and contain only numbers and Latin letters.
-
Bundle ID: Get the bundle ID
in your Apple developer account: Certificates, Identifiers & Profiles → Identifiers or in the Xcode app: Target → General → Identity. It may contain only numbers, Latin letters, hyphens, and periods.
Learn more about the token in the relevant Apple documentation
. -
-
To authenticate using a certificate, you will need the following data:
- Certificate: SSL certificate file in
.pem
format. - Private certificate key: Key file in
.pem
format.
For more information about the certificate, see the Apple documentation
.To save the certificate and the private key in individual
.pem
files, use the openssl Linux utility:openssl pkcs12 -in Certificates.p12 -nokeys -nodes -out certificate.pem openssl pkcs12 -in Certificates.p12 -nocerts -nodes -out privatekey.pem
- Certificate: SSL certificate file in
Token-based authentication is preferred as a faster, more modern and secure option.
-
-
For Environment, select either
Development
orProduction
. UseDevelopment
to test the application.
Google Android
Specify which FCM API version will be used:
HTTP v1
orLegacy
.You can authenticate with FCM using either the HTTP v1 API or Legacy API:
- To authenticate using the HTTP v1 API, you will need a Google Cloud service account key in JSON format. The key is used to generate OAuth 2.0 temporary tokens for authenticating requests in the FCM HTTP v1 API. You can get it in the Google Cloud management console.
- To authenticate using the Legacy API, you will need an API key (server key). You can get it in the Firebase management console.
Note
The HTTP v1 API is preferred as FCM will no longer support
the Legacy API starting from June 2024.See more in the Firebase documentation
.Huawei Android
You can authenticate with HMS using the following parameters:
- Key ID
- API key
See more in the HMS documentation
. -
-
Enter a name for your notification channel. The name must be unique within the cloud. It may contain lowercase and uppercase Latin letters, numbers, underscores, hyphens, and periods. It may be from 1 to 256 characters long. For APNs channels, we recommend specifying the bundle ID in the name, and for FCM and HMS, the full package name.
-
(Optional) Click
Add description and enter a description for your notification channel. -
Click Create.
Creating a notification channel may take some time.
Create an endpoint
Each channel has its own base of endpoints to send notifications directly to the app on user devices.
To create an endpoint:
- Select the notification channel you previously created.
- Go to the
Endpoints tab. - Click Create endpoint.
- Enter the Device token, i.e., a unique token on the user device created by the notification service for the app.
- (Optional) Enter the User data: UTF-8
encoded text up to 2,048 characters long. - Click Create.
Creating an endpoint may take some time.
Send a notification
- Select the endpoint you previously created.
- Under Sending notifications, select the notification format:
Text
orJSON
. - Enter notification text or a JSON object with notification data.
- Click Send.
Each sent notification is assigned a unique ID. To save it, click Copy ID.
You can send a new notification immediately or resend the previous one.