Amazon AWS SNS
Postways supports Amazon AWS SNS for sending mobile push notifications. If you're not already using SNS to send mobile push notifications then you might consider doing so. However, before diving into the nitty gritty, it might be good to discuss a few SNS concepts first, such as Publish / Subscribe.
Publish / Subscribe
Many developers, when they are first introduced to AWS SNS think of SNS as a service for sending out mobile text messages (SMS) and mobile push notifications. It is true that SNS allows you to send out mobile text messages and push notifications, including to platforms such as; Android GCM and Apple's APNS, however, SNS is actually a Pub/Sub system and the mobile text and push notifications are just two of the type of subscribers that SNS supports.
In a way, you can think of SNS as an accompany service to AWS SQS. The use case for SQS is obviously different from that of SNS, but the similarity is that both SNS and SQS revolve around sending messages. The difference between SQS and SNS is that SQS works with queues and messages are retained in a queue until they are processed by a consumer. SNS on the other hand works with topics and messages are immediately forwarded to all subscribers of a topic the moment a message is published. This makes SQS great for processing of tasks in a sequencial manner (e.g. background tasks) and it makes SNS great for real-time (or near real-time) notifications or tasks that can (or should) be performed in parallel.
Some of the high level similarities and differences between SQS and SNS are:
As you can see in the table above, there are some similarities between SQS and SNS, however, SQS works with queues and SNS works with topics. SQS works with consumers and SNS works with subscribers.
Topics & Subscribers
SNS works with topics and you publish messages to a topic. Once a message is published to a topic it will be forwarded immediately to all subscribers of that topic. In SNS the subscribers can be of a wide variety of types. A subscriber can be a HTTP end point, an AWS Lambda function, an email address, an SQS queue, a mobile phone number (SMS) or a mobile push device.
With this understanding you might begin to realize that SNS isn't so much about sending mobile push notifications as such, but that the foundation of SNS is actually much broader and might be considered an integral part of AWS as the programmable cloud. Meaning, with SNS you could have a CloudWatch metric publish a message into an SNS topic that might have a Lambda function as a subscriber that will perform some auto scaling functionality within your AWS environment.
Mobile Push Notifications
SNS provides a great abstraction to some of the popular mobile push notification platforms. The way you work in SNS with mobile push notifications is by creating a Platform Application for each of the platforms you want to be able to send mobile push notifications over. E.g. if you want to send mobile push notifications to both Android and iOS then you will need to create two Platform Applications within SNS, one for Android and one for iOS. You need to supply each of these Platform Applications with the credentials provided to you by each of the platforms. E.g. to create an Android Platform Application in SNS you need to supply the API Key generated and provided by Google (GCM/Firebase) and to create a iOS Platform Application in SNS you need to supply the certificates generated and provided by Apple APNS.
Once the Platform Applications have been created in SNS you can start to create Platform End Points. E.g. if a user of your application on an Android device registers with your mobile app, the mobile app will be able to obtain a unique device token for that user/app combination on the mobile device. On an Android device this will be provided by GCM and normally you would store this token in your own database. In the event you want to send a push notification to the users' device, you provide this token to GCM and the push notification will be send to that device.
However, with SNS it is required that you first create a Platform End Point with the GCM provided device token. For an Android device token you do this by using the Android Platform Application ARN (provided by SNS when the Platform Application was created) and the Android device token. By creating the Platform End Point, SNS will return a Platform End Point ARN. You need to store this Platform End Point ARN in your local database (instead of the GCM device token) and when it's time to send a push notification to the user's mobile device, you simply publish the message to the Platform End Point ARN through SNS. SNS will then inturn communicate with GCM for the actual sending of the message.
Within the context of Postways, it is the responsibility of your application to manage the Platform Application and the Platform End Points, in the same way that it is the responsibility of your application to manage your users email addresses and/or phone numbers. However, once your have the Platform End Point ARN's for each of your users with mobile devices, you can now send mobile push notifications through Postways to those users by providing the Platform End Point ARN. Since the Platform End Point ARN is linked to the Application Platform, SNS is capable of figuring out to which push notification platform it must forward the message to.
Please refer to the AWS SNS documentation for more information.