I'm implementing push notifications in an iOS app using Amazon SNS and Amazon Cognito services.
Cognito saves tokens successfully, my app gets notified, everything's working well, but there is a thing.
Now, when still in development, I need to manually add endpoints to an SNS topic, so all subscribers can get notifications. When i'll push an update to the App Store, there will be thousands of tokens to add.
I was studying Amazon AWS documentation, but there was no clue whether it's possible to make it happen without that additional effort.
My question: is it possible to automatically subscribe an endpoint to a topic with Amazon services only?
Best Answer
There is no way to automatically subscribe an endpoint to a topic, but you can accomplish all through code.
You can directly call the
Subscribe
API after you have created your endpoint. Unlike other kinds of subscription, no confirmation is necessary with SNS Mobile Push.Here is some example Objective-C code that creates an endpoint and subscribes it to a topic:
Make sure you have granted access to
sns:Subscribe
in your Cognito roles to allow your application to make this call.Update 2015-07-08: Updated to reflect AWS iOS SDK 2.2.0+