简体   繁体   中英

Is there a way in AWS Simple Notification Services (SNS) to track who all unsubscribed?

We're using AWS SNS (Simple Notification Services) as one of the mechanisms of sending out notifications for users. That means, there are notifications sent through SMS (using AWS SNS) / Emails / automated calls.

But any time, if a user unsubscribes from any of these three methods, We should stop sending further alerts to the user in all the three modes.

Currently I don't have a way in API to check if a subscription request has been opted-out (by sending a STOP message), so that we can block the other two modes of communications as well.

Is it possible, in SNS? I've tried looking into the list of API, console and Amazon Forums.

I've figured out that this below behaviour of AWS SNS (for SMS end points) can be a workaround.

Although currently there is no way of getting a list of endpoints (users) who unsubscribe by responding STOP to 30304 (Amazon's short number.)

But, when we subscribe a user for a topic, AWS creates a subscription record with subscriptionArn = "PendingConfirmation"

If the user responds STOP (opts out), the subscription record is deleted from the topic. If the user subscribes to it, the subscription's subscriptionArn changes to some valid ARN (Amazon's resource Number) from "PendingConfirmation".

ListSubscriptionsByTopic API lists the user subscription even if it is in "PendingConfirmation" state.

So for now, only way to know if a user has unsubscribed from the topic would be, maintaining a list of users with their end points (phone numbers / email ids) and comparing it at later point of time with the list of available list of subscriptions. If something has disappeared, it means they've unsubscribed.

Of course, it can't be real-time. But this is the only workaround that is available for now.

As an additional info, if a subscription is pending for more than 72 hours, it is automatically deleted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM