SNS (Amazon Simple Notification Services)
Amazon SNS (Amazon Simple Notification Services) is a notification service used to send the notification to the subscribed endpoint or devices. It is provided as a part of Amazon Web Services. It provides a low-cost infrastructure for the mass delivery of messages, emails, notification etc.
Steps to implementing Amazon SNS
- Create topic - you will get the Topic ARN for which you have to send the notification or send the messages.
- Create Application - after this, you have to create an application whether you want to send the notification over the Android application or over the iOS application.
- Create Endpoint - you need to create the endpoint and subscribe to that endpoint on which you have to publish the message or send the notification.
- Publish Message - the last step is to publish the message or send the notification to the endpoint.
You can follow the same process for using this notification service over the Amazon Console too. You need to login to the console first. After that, you will see a screen like this.
Type "Simple Notification Service" in the textbox and select from the results shown on the screen.
Here, you will have the list of topics, subscriptions, application, and endpoints that you create. In the above screenshot, I have created two endpoints - one for Android devices (GSM) and the other one for iOS devices (APNS).
For using the ASNS from the console, the steps are same as described above. I am going to show a working example of the ASNS in .NET using Visual Studio.
Lets begin.
Step 1
Install AWS Toolkit for Visual Studio.
Step 2
Create a Windows or web application whatever you want. I have created a Windows.Form application and have taken two radio buttons and one submit button to send notification.
Step 3
After this, you need to setup your project to use the Amazon Services. First, you have to specify the Access Key, Secret Key, and Region in web.config in case you are using the web application; and in app.config if you are using the Windows application.
- <appSettings>
- <add key="AWSAccessKey" value="************************" />
- <add key="AWSSecretKey" value="*******************************************" />
- <add key="AWSRegion" value="us-east-1" />
- </appSettings>
Remember, the key name must be in the case as mentioned.
Step 4
After this, you need to install a few of the necessary .dll files from the NuGet Package Manager. You can add these required libraries from the NuGet Package Manager or PM> console by typing the name of the libraries, as shown in references.
Now, it's time to write a few lines of code for the same.
If you get the message "Notification send successfully", you have successfully integrated this SNS Service in your application.
For the live testing on your devices, you must have to be ready with your device (IOS/Android) on which you are going to test this. I hope, you will enjoy implementing this awesome service of Amazon.
If you have any query or questions, I will be happy to give the solution,
Happy coding! Enjoy.