Skip to main content

AWS SNS Push Notifications

AWS Simple Notification Service (SNS) enables sending push notifications to mobile devices through its API.

Configuration

Database Setup

Create a new entry in the notify_providers table with the following settings:
FieldValue
channel_type9 (Push Notification SNS)
is_enabled1

Configuration Fields

AWS_ACCESS_KEY_ID
string
required
Access key for AWS instance
AWS_SECRET_ACCESS_KEY
string
required
Secret access key for AWS
AWS_REGION
string
required
Region of the AWS instance
Example Configuration:
{
  "AWS_ACCESS_KEY_ID": "Aws-Access-key",
  "AWS_SECRET_ACCESS_KEY": "Aws-Secret-Key",
  "AWS_REGION": "us-west-2"
}

Request Format

Sample Request Body

{
  "providerId": 10,
  "data": {
    "message": {
      "GCM": "{\"notification\":{\"title\":\"Test Notification\",\"body\":\"This is a test notification\"}}"
    },
    "target": "arn:aws:sns:us-west-2:505884080245:endpoint/GCM/Android/7fb080a5-..."
  }
}

Request Fields

message
object
required
Platform-specific message payload. The key is the platform (e.g., GCM for Android, APNS for iOS).
target
string
required
The ARN of the endpoint to send the notification to

Message Format for Different Platforms

{
  "GCM": "{\"notification\":{\"title\":\"Title\",\"body\":\"Message body\"}}"
}
The message payload must be a JSON string, not a JSON object. Notice the escaped quotes in the examples above.

Dependencies

PackageVersionDescription
@aws-sdk/client-sns^3.855.0AWS SDK for JavaScript SNS client

References