Creating 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. -
From the list of services, select Cloud Notification Service.
-
Click Create notifications 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.RuStore Android
: For Android devices with the RuStore app marketplace installed.
-
Depending on the platform you select, set the authentication parameters:
Apple iOS
-
Select the Authentication method:
Token
orCertificate
.-
To authenticate with a token, you will need:
-
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 with a certificate, you will need:
- 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.
-
-
Select the Environment:
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 the API:
- 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.
- Legacy API: You will need an API key (server key). You can get it in the Firebase management console.
Note
FCM no longer supports
the legacy API starting June 2024.See more in the Firebase documentation
.Huawei Android
Explore the HMS documentation
and get the authentication parameters:- Key ID.
- API key.
RuStore Android
See the relevant RuStore article
and get the authentication parameters:- Project ID.
- Service token.
You can get your authentication parameters in the RuStore developer console: Push notifications → Projects.
-
-
Enter the notification channel Name. Channel names are unique within the entire CNS. 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; for FCM and HMS, the full package name; for RuStore,
packageName
. -
Optionally, click
Add description and enter a description for your notification channel. -
Click Create.
-
If you do not have the AWS CLI yet, install and configure it.
-
Run this command:
aws sns create-platform-application \ --name <channel_name> \ --platform <platform_type> \ --attributes <parameter1>=<value1>, ... <parameterN>=<valueN>
Where:
-
--name
: Notification channel name, user-defined.The name must be unique throughout CNS. Once the channel is created, you will not be able to change the name. The name may contain lowercase and uppercase Latin letters, numbers, underscores, hyphens, and periods. It must be from 1 to 256 characters long. For APNs channels, we recommend specifying the bundle ID in the name; for FCM and HMS, the full package name; for RuStore,
packageName
. -
--platform
: Mobile platform type:APNS
andAPNS_SANDBOX
: Apple Push Notification service (APNs). UseAPNS_SANDBOX
to test the application.GCM
: Firebase Cloud Messaging (FCM).HMS
: Huawei Mobile Services (HMS).RUSTORE
: RuStore Android.
-
--attributes
: Mobile platform authentication parameters in<parameter>=<value>
format, comma-separated. The values depend on the platform:-
APNs:
-
Token-based authentication:
PlatformPrincipal
: Path to the signature key file from Apple.PlatformCredential
: Key ID.ApplePlatformTeamID
: Team ID.ApplePlatformBundleID
: Bundle ID.
-
Certificate-based authentication:
-
PlatformPrincipal
: SSL certificate in.pem
format. -
PlatformCredential
: Certificate private key in.pem
format.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
-
Token-based authentication is preferred as a more modern option.
-
-
FCM:
PlatformCredential
is the Google Cloud service account key in JSON format for authentication with the HTTP v1 API or API key (server key) for authentication with the legacy API.We recommend escaping the file contents using the
jq @json <<< cat private_key.json
command, as the AWS CLI accepts this parameter in string format.The HTTP v1 API is preferred as FCM will no longer support
the legacy API starting from June 2024. -
HMS:
PlatformPrincipal
: Key ID.PlatformCredential
: API key.
-
RuStore:
PlatformPrincipal
: Project ID (ProjectID).PlatformCredential
: Service token (ServiceToken).
-
As a result, you will get a notification channel ID (ARN). Save it for future use.
For more information about the
aws sns create-platform-application
command, see the AWS documentation . -
-
If you do not have the AWS SDK for Python (boto3) yet, install and configure it.
-
To create a push notification channel, use the following code:
response = client.create_platform_application( Name="<channel_name>", Platform="<platform_type>", Attributes= { "<параметр1>": "<значение1>", ... "<parameterN>": "<valueN>" } ) print ("Platform application ARN:", response['PlatformApplicationArn'])
Where:
-
Name
: Notification channel name, user-defined.The name must be unique throughout CNS. Once the channel is created, you will not be able to change the name. The name may contain lowercase and uppercase Latin letters, numbers, underscores, hyphens, and periods. It must be from 1 to 256 characters long. For APNs channels, we recommend specifying the bundle ID in the name; for FCM and HMS, the full package name; for RuStore,
packageName
. -
Platform
: Mobile platform type:APNS
andAPNS_SANDBOX
: Apple Push Notification service (APNs). UseAPNS_SANDBOX
to test the application.GCM
: Firebase Cloud Messaging (FCM).HMS
: Huawei Mobile Services (HMS).RUSTORE
: RuStore Android.
-
Attributes
: Mobile platform authentication parameters in"<parameter>": "<value>"
format, comma-separated. The values depend on the platform:-
APNs:
-
Token-based authentication:
PlatformPrincipal
: Path to the token signature key file from Apple.PlatformCredential
: Key ID.ApplePlatformTeamID
: Team ID.ApplePlatformBundleID
: Bundle ID.
-
Certificate-based authentication:
-
PlatformPrincipal
: SSL certificate in.pem
format. -
PlatformCredential
: Certificate private key in.pem
format.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
-
Token-based authentication is preferred as a more modern option.
-
-
FCM:
PlatformCredential
is the Google Cloud service account key in JSON format for authentication with the HTTP v1 API or API key (server key) for authentication with the Legacy API.The HTTP v1 API is preferred as FCM will no longer support
the Legacy API starting June 2024. -
HMS:
PlatformPrincipal
: Key ID.PlatformCredential
: API key.
-
RuStore:
PlatformPrincipal
: Project ID (ProjectID).PlatformCredential
: Service token (ServiceToken).
-
As a result, you will get a notification channel ID (ARN).
-
-
If you do not have the AWS SDK for PHP yet, install and configure it.
-
To create a push notification channel, use the following code:
$response = $client->createPlatformApplication( [ 'Name' => '<channel_name>', 'Platform' => '<platform_type>', 'Attributes' => [ '<parameter1>' => '<value1>', ... '<parameterN>' => '<valueN>' ], ] ); print($response->get('PlatformApplicationArn'));
Where:
-
Name
: Notification channel name, user-defined.The name must be unique throughout CNS. Once the channel is created, you will not be able to change the name. The name may contain lowercase and uppercase Latin letters, numbers, underscores, hyphens, and periods. It must be from 1 to 256 characters long. For APNs channels, we recommend specifying the bundle ID in the name; for FCM and HMS, the full package name; for RuStore,
packageName
. -
Platform
: Mobile platform type:APNS
andAPNS_SANDBOX
: Apple Push Notification service (APNs). UseAPNS_SANDBOX
to test the application.GCM
: Firebase Cloud Messaging (FCM).HMS
: Huawei Mobile Services (HMS).RUSTORE
: RuStore Android.
-
Attributes
: Mobile platform authentication parameters in'<parameter1>' => '<value1>'
format, comma-separated. The values depend on the platform:-
APNs:
-
Token-based authentication:
PlatformPrincipal
: Path to the token signature key file from Apple.PlatformCredential
: Key ID.ApplePlatformTeamID
: Team ID.ApplePlatformBundleID
: Bundle ID.
-
Certificate-based authentication:
-
PlatformPrincipal
: SSL certificate in.pem
format. -
PlatformCredential
: Certificate private key in.pem
format.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
-
Token-based authentication: The more modern and secure method.
-
-
FCM:
PlatformCredential
is the Google Cloud service account key in JSON format for authentication with the HTTP v1 API or API key (server key) for authentication with the legacy API.Use the HTTP v1 API because the FCM legacy API is no longer supported
starting July 2024. -
HMS:
PlatformPrincipal
: Key ID.PlatformCredential
: API key.
-
RuStore:
PlatformPrincipal
: Project ID (ProjectID).PlatformCredential
: Service token (ServiceToken).
-
As a result, you will get a notification channel ID (ARN).
-
Use the create HTTP API method for the PlatformApplications resource in Yandex Cloud Notification Service.
Creating a notification channel may take some time.