How to subscribe AWS SNS Topic in React Native (Android)?


I tried with the aws-sdk-react-native module:

The configuration took some time, but thanks to this links I could i.e. list the topics:

The test includes a sample how to subscribe to get emails but not how to get notifications in the app. I don’t know how to get the platformEndpoint, the PlatformApplicationArn and the deviceToken.

Are there any samples for this?
I’m also looking for an authentication sample.
Would it be easier to use firebase?



I have used GCM over SNS to send notifications. Here are the steps I went through assuming you already set up GCM and added required libraries from AWS React Native SDK:

First create a SNS app from AWS:

enter image description here

Then you need to create Federated Identity through Cognito service of AWS. This is required for sending your device token from mobile app to AWS SNS app. Choose Manage Federated Identities

enter image description here

Then create your pool, don’t forget to check Enable Access to unauthenticated identities
enter image description here

When you create the pool you will need to create IAM Roles for unauthenticated and authenticated roles of that pool. AWS will help you create new roles for that but you need to go to IAM Roles menu and attach AmazonSNSFullAccess to created roles, otherwise from the mobile app you won’t able to send device token.

enter image description here

After doing these steps you will able send your device token using Amazon’s React Native SDK. I have written a helper class for sending token to AWS SNS as suggested here:

Leave a Reply