Skip to main content

AWS SNS Push Notifications Guide

This guide provides detailed information on sending push notifications through AWS SNS.

Prerequisites

Before sending push notifications, ensure you have:

AWS Account

An active AWS account with SNS access

IAM Permissions

IAM user with appropriate SNS permissions

SNS Topic

An SNS topic configured for your application

Platform Application

Platform application in SNS (GCM for Android, APNS for iOS)

Message Payload Structure

The payload consists of two fields:
message
object
required
The properly formatted notification payload (platform-specific)
target
string
required
The endpoint ARN for the target device

Platform-Specific Payloads

{
  "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/MyApp-Android/7fb080a5-..."
  }
}

Android Payload Fields

FieldDescriptionExample
titleNotification title"New Message"
bodyNotification body text"You have a new message"
iconIcon to display"ic_notification"
soundSound to play"default"
click_actionAction on click"OPEN_ACTIVITY"
dataCustom key-value pairs{"key1": "value1"}
priorityMessage priority"normal" or "high"
ttlTime to live"3600s" (1 hour)

Complete Field Reference

Android (GCM/FCM) Fields

Specifies the notification title displayed in the notification drawer.
"title": "New Message"
Specifies the main content users see in the notification drawer.
"body": "You have a new message"
Specifies the icon to display with the notification.
"icon": "ic_notification"
Specifies the sound to play when the notification arrives.
"sound": "default"
Defines the action to perform when the user clicks the notification.
"click_action": "OPEN_ACTIVITY"
Provides additional custom data to the application.
"data": {"key1": "value1", "key2": "value2"}
Sets the priority of the message. Valid values: "normal" and "high".
"priority": "high"
Time to live. Specifies how long the message should be kept if the device is offline.
"ttl": "3600s"

iOS (APNS) Fields

Contains the notification’s title and body.
"aps": {
  "alert": {
    "title": "New Message",
    "body": "You have a new message"
  }
}
Sets the number to display on the app icon.
"aps": {
  "badge": 1
}
Indicates new content is available and can trigger background processing.
"aps": {
  "content-available": 1
}
Used to define custom actions for the notification.
"aps": {
  "category": "NEW_MESSAGE_CATEGORY"
}

Usage in OsmoX

When sending push notifications through OsmoX:
  1. Format the message payload according to the target platform
  2. Provide the correct endpoint ARN as the target
  3. OsmoX passes the message to AWS SNS for delivery
Ensure the message payload is correctly formatted for the target platform. Incorrect formatting will result in delivery failures.

References