Sending a push notification
Written by
Updated at April 17, 2025
Management console
AWS CLI
AWS SDK for Python
AWS SDK for PHP
AWS SDK for JavaScript
API
- In the management console
, go to the folder containing your endpoint. - From the list of services, select Cloud Notification Service.
- Select an in-browser push notification channel.
- Navigate to the
Endpoints tab. - Select the endpoint you need.
- Enter the notification text and click Send.
Each sent notification is assigned a unique ID. To save it, click Copy ID.
-
If you do not have the AWS CLI yet, install and configure it.
-
Run this command:
aws sns publish \ --target-arn "<endpoint_ARN>" \ --message-structure json \ --message '{"default": "<notification_text>", "WEB": "<notification_text>"}'
Where:
--target-arn
: Endpoint ID (ARN).--message-structure
: Message format.--message
: Message.
-
If you do not have the AWS SDK for Python (boto3) yet, install and configure it.
-
To send a notification, use this code:
try: response = client.publish( TargetArn="<endpoint_ARN>", Message=json.dumps({ "default": "<notification_text>", "WEB": "<notification_text>", }), MessageStructure="json", ) print(f'Message ID: {response["MessageId"]}') except botocore.exceptions.ClientError as error: print(f"Error: {error}")
-
If you do not have the AWS SDK for PHP yet, install and configure it.
-
To send a notification, use this code:
$response = $client->publish( [ 'TargetArn' => '<endpoint_ARN>', 'Message' => json_encode([ 'default' => '<notification_text>', 'WEB' => '<notification_text>', ]), 'MessageStructure' => 'json', ] ); print('Message ID: ' . $response->get('MessageId'));
-
If you do not have the AWS SDK for JavaScript yet, install and configure it.
-
To send a notification to a browser, use this code:
try { const response = await client.send( new AWS.PublishCommand({ Message: JSON.stringify({ "default": "<notification_text>", "WEB": "<notification_text>", }), MessageStructure: "json", TargetArn: "<endpoint_ARN>", }), ); console.log("Message ID:", response["MessageId"]); } catch (e) { console.log("Error:", e) }
Use the HTTP API publish method for the Yandex Cloud Notification Service Publish resource.