Receiving via AWS SNS
Receiving notifications via AWS SNS (Simple Notification Service) with the Neo Cast Delivery Nodes is a powerful way to integrate web3 communication directly into your platform using webhooks. Here are the steps to get started with the Hosted SNS Module:
3 Steps for Getting Started With Hosted SNS Module:
Step 1: Implement a Webhook Implement a webhook in your code to listen to incoming notifications. You can use a provided boilerplate along with specifications to get started. Here's the npm package to help you get started.
Step 2: Open an Endpoint You'll need to open an endpoint, either on a dedicated IP or, if you're testing locally, expose a public endpoint. You can use tools like ngrok to expose a local endpoint. If you use ngrok with the provided boilerplate, the port should be set to 6000. After setting up your endpoint, contact the Neo Cast team to whitelist your webhook endpoint. This step is essential for the SNS module to work.
Step 3: Configure and Receive Notifications Once your webhook is set up and your endpoint is whitelisted, you can start receiving notifications, chats, or any other web3 communication in your software.
SNS Sample Messages:
Subscription Confirmation: This is a one-time message confirming that the SNS subscription is successful.
Notification: These are the actual notifications that need to be delivered to end users. Here's an example of a notification message:
{
"Type": "Notification",
"MessageId": "62918f56-9bce-5497-a23e-d422c782a01d",
"TopicArn": "arn:aws:sns:us-east-1:293359341249:dev-epns-notifications",
"Message": "{\"sid\":121,\"users\":[\"0x35B84d6848D16415177c64D64504663b998A6ab4\"],\"payload\":{\"apns\":{\"payload\":{\"aps\":{\"category\":\"withappicon\",\"mutable-content\":1,\"content-available\":1}},\"fcm_options\":{\"image\":\"https://gateway.ipfs.io/ipfs/QmQM97KUTGTT6nt6Xd7xAJpdGB8adiJ1LVUJoN8RoFUYfx\"}},\"data\":{\"app\":\"Shunya\",\"sid\":\"121\",\"url\":\"https://shunya.fi/\",\"acta\":\"https://shunya.fi\",\"aimg\":\"https://shunya.fi/_nuxt/img/shunya.cfece51.png\",\"amsg\":\"Your portfolio is up by 0.08% since yesterday.\",\"asub\":\"Assets Daily\",\"icon\":\"https://gateway.ipfs.io/ipfs/QmQM97KUTGTT6nt6Xd7xAJpdGB8adiJ1LVUJoN8RoFUYfx\",\"type\":\"3\",\"epoch\":\"1660554419\",\"appbot\":\"0\",\"hidden\":\"0\",\"secret\":\"\"},\"android\":{\"notification\":{\"icon\":\"@drawable/ic_stat_name\",\"color\":\"#e20880\",\"image\":\"https://gateway.ipfs.io/ipfs/QmQM97KUTGTT6nt6Xd7xAJpdGB8adiJ1LVUJoN8RoFUYfx\",\"default_vibrate_timings\":true}},\"notification\":{\"body\":\"Your portfolio is up by 0.08% since yesterday.\",\"title\":\"Shunya - Assets Daily\"}},\"epoch\":\"1660554419\",\"topic\":\"Notification\",\"subtopic\":\"Channel\"}",
"Timestamp": "2022-08-15T14:37:00.408Z",
"SignatureVersion": "1",
"Signature": "...",
"SigningCertURL": "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-56e67fcb41f6fec09b0196692625d385.pem",
"UnsubscribeURL": "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:293359341249:dev-epns-notifications:cc473de2-b46e-462c-95d4-178580487a26"
}
The "Message" field in the JSON contains the actual notification sent from Neo Cast in a stringified JSON format.
Message Fields Explanation:
sid
: Unique ID from Neo Cast.users
: List of wallet addresses for which the notification needs to be delivered.payload
: The actual payload to be delivered to the user's device.epoch
: Timestamp when the payload is generated.topic
: The type of payload (e.g., Notification, Chat, etc.).subtopic
: The mode of delivery (e.g., Channel or User level).
These messages provide essential information for your software to process and display notifications to users. You can use the content within the payload
field to customize how notifications are presented to your users.
Last updated