AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Sends a message to an Amazon SNS topic or sends a text message (SMS message) directly to a phone number.

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 has been saved and Amazon SNS will attempt to deliver it shortly.

To use the Publish action for sending 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.

Note:

For .NET Core, PCL and Unity this operation is only available in asynchronous form. Please refer to PublishAsync.

Namespace: Amazon.SimpleNotificationService
Assembly: AWSSDK.SimpleNotificationService.dll
Version: 3.x.y.z

Syntax

C#
public virtual PublishResponse Publish(
         PublishRequest request
)
Parameters
request
Type: Amazon.SimpleNotificationService.Model.PublishRequest

Container for the necessary parameters to execute the Publish service method.

Return Value
The response from the Publish service method, as returned by SimpleNotificationService.

Exceptions

ExceptionCondition
AuthorizationErrorException Indicates that the user has been denied access to the requested resource.
EndpointDisabledException Exception error indicating endpoint disabled.
InternalErrorException Indicates an internal service error.
InvalidParameterException Indicates that a request parameter does not comply with the associated constraints.
InvalidParameterValueException Indicates that a request parameter does not comply with the associated constraints.
InvalidSecurityException The credential signature isn't valid. You must use an HTTPS endpoint and sign your request using Signature Version 4.
KMSAccessDeniedException The ciphertext references a key that doesn't exist or that you don't have access to.
KMSDisabledException The request was rejected because the specified customer master key (CMK) isn't enabled.
KMSInvalidStateException The request was rejected because the state of the specified resource isn't valid for this request. For more information, see How Key State Affects Use of a Customer Master Key in the AWS Key Management Service Developer Guide.
KMSNotFoundException The request was rejected because the specified entity or resource can't be found.
KMSOptInRequiredException The AWS access key ID needs a subscription for the service.
KMSThrottlingException The request was denied due to request throttling. For more information about throttling, see Limits in the AWS Key Management Service Developer Guide.
NotFoundException Indicates that the requested resource does not exist.
PlatformApplicationDisabledException Exception error indicating platform application disabled.

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5

Portable Class Library:
Supported in: Windows Store Apps
Supported in: Windows Phone 8.1
Supported in: Xamarin Android
Supported in: Xamarin iOS (Unified)
Supported in: Xamarin.Forms

Unity:
Supported Versions: 4.6 and above
Supported Platforms: Android, iOS, Standalone

See Also