Amazon SNS dynamic topics case scenario
In my case scenario I need to send push notifications every time a user posts a new message into a thread. It's like a mobile app forum. You can post messages into threads and then you can reply messages. I'm trying to migrate from custom APNS code to Amazon SNS in order to simplify and get rid of code manteinance. But as far as I know, I need topics to publish push notifications in order to deliver a push to all the people inside a discussion thread.
In my custom approach, I send the device tokens to an async task and deliver that bulk of messages in one APNS connection. Thus, this is like a "dynamic topic" I'm generating each time a new message is posted into a thread (I notify all the participants of a thread, and that number should be able to scale from a few to thousands).
How can this approach be done with Amazon SNS? Do I have to create a topic for each thread? Instead of connecting and writing all the push messages into APNS, can I mantain this approach with Amazon SNS only knowing the device token of the receivers?
You can use Direct Addressing to send push notifications without creating topics. Create your application inside Amazon SNS using CreatePlatformApplication
. Then, register each token with the application using CreatePlatformEndpoint
. You will receive an Endpoint ARN for each token.
You can now use the SNS Publish
API to send a message to each Endpoint ARN. You can experiment with Direct Addressing with the Amazon SNS Console.
上一篇: 亚马逊SNS太慢等问题
下一篇: Amazon SNS动态主题案例场景