Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PublishCommand

Sends a message to an Amazon SNS topic, a text message (SMS message) directly to a phone number, or a message to a mobile platform endpoint (when you specify the TargetArn).

If you send a message to a topic, Amazon SNS delivers the message to each endpoint that is subscribed to the topic. The format of the message depends on the notification protocol for each subscribed endpoint.

When a messageId is returned, the message is saved and Amazon SNS immediately deliverers it to subscribers.

To use the Publish action for publishing a message to a mobile endpoint, such as an app on a Kindle device or mobile phone, you must specify the EndpointArn for the TargetArn parameter. The EndpointArn is returned when making a call with the CreatePlatformEndpoint action.

For more information about formatting messages, see Send Custom Platform-Specific Payloads in Messages to Mobile Devices.

You can publish messages only to topics and endpoints in the same Amazon Web Services Region.

example

Use a bare-bones client and the command you need to make an API call.

import { SNSClient, PublishCommand } from "@aws-sdk/client-sns"; // ES Modules import
// const { SNSClient, PublishCommand } = require("@aws-sdk/client-sns"); // CommonJS import
const client = new SNSClient(config);
const command = new PublishCommand(input);
const response = await client.send(command);
see

PublishCommandInput for command's input shape.

see

PublishCommandOutput for command's response shape.

see

config for SNSClient's config shape.

Hierarchy

Implements

Index

Constructors

Properties

Constructors

constructor

  • Parameters

    Returns PublishCommand

  • Parameters

    • input: PublishCommandInput

    Returns PublishCommand

Properties

Readonly input

input: PublishCommandInput

Readonly middlewareStack

middlewareStack: IMiddlewareStack<PublishCommandInput, PublishCommandOutput>