Today I will be showing you how to set up AWS SNS. The Amazon Web Services (AWS) Simple Notification Service (SNS) is a service that allows developers to use the AWS infrastructure to send Push notifications to devices (it can also be used to send SMS or messages to other services like the AWS Queue, but these are not in the scope of this tutorial).
Push notification are those messages that smartphone/tablet users receive that popups in the device screen. They are called as "Push" because it is the server that pushes the message to the device and not the app that requests the message from the server.
Let's start.
#1) Log into your AWS Management Console and click on "SNS Services" under the "App Services" category.
Application Name: You can choose any app. I like to set a name that relates to the app that this SNS will provide the messages
Push Platform: You need to choose what platform will this SNS use. If your app is an iOS app, you need to choose the Apple Push Notification Service (APNS). During development, it is recommended to use the Apple Push Notification Service Sandbox (APNS_Sandbox). You also have the option to choose the Google service or Amazon. We will choose here Apple Push Notification Service Sandbox.
Credentials: in this section you will have to enter the credentials of the Push Platform selected above. On the APNS, we need to enter the Certificate and Private Key. We can enter them directly in the box or we can simply select the P12 private key file and the Certificate and Private Key info will be automatically filled. Let's do it by the simple way (choosing the file).
#4.1) Access your Keychain Access and select "Login" in the Keychains#4.2) Make a right click on the correct app private key and select Export.
#6) Enter the password that you set on the item #4.3 and press "Load Credentials from File"
#7) Now, just click on "Add New App"
You maybe thinking: "Ok, but how do I send a Push message?". Well first you need to register the device that will receive the Push Notification with the SNS service.
In SNS Dashboard of the app that you just configured, you can see the devices that are registered to receive the Push Notification. Since, we just configured the service, we have none. You need to make your app (in this case an iOS app) to register the user iPhone/iPad with the SNS Service. You do that by passing the device push token that Apple will provide to your app. If you already have that token and just want to test the SNS Service, you can add it manually by clicking on "Add Endpoints" (Endpoint in our environment here is a user device). The EndpoinArn info that you also see in the console is like the "AWS SNS token" for that device. After you add a iOS device token, the SNS you create a EndpointArn.
To send a Push notification to that device, just select it and go on "Endpoint Actions -> Publish". Just type the message and click on "Publish Message". If you set everything right, you should receive a Push notification on that device.
Of course, sending Push Messages manually for you game/app is not very fun. So, you need to have a server and configured it to communicate with the AWS SNS and send the messages for you. AWS has SDKs for several languages (.NET, PHP,...), so you can get the SDK go thru their documentation to configure your server.