Reputation: 3313
System: Windows, C#, Visual Studio 2015, AWSSDK.SimpleNotificationService
Using AWS-SNS, after creating a topic I add a subscription to the topic as follows;
var response = SnsClient.Subscribe(topicArn, "email", email);
var subscriptionArn = response.SubscriptionArn;
Initially, my subscription ARN is set to "pending confirmation" - presumably until the user confirms their subscription via email. I would have thought that calling subscribe again with the same email subsequent to confirmation would have returned a vilid ARN, but it doesn't seem to work that way.
Not having the subscription ARN prevents me from later unsubscribing an email from a subscription group. I'm sure there is a way to overcome it short of requiring the user to copy / past the email token into my application - but I can't seem to find it.
Thank you in advance.
SteveJ
(PS. I should note that the answer need to be C# specific - just a generic approach to the problem using their SDK or web API is fine.)
Upvotes: 0
Views: 1461
Reputation: 269081
The Amazon SNS Subscribe documentation says:
The following element is returned by the service:
SubscriptionArn
The ARN of the subscription, if the service was able to create a subscription immediately (without requiring endpoint owner confirmation).
Therefore, it appears that an Email subscription only receives an ARN when the subscription has been confirmed.
You will need to identify the subscription (once subscribed) by calling ListSubscriptionsByTopic
, looking for the Endpoint
that matches the desired email address. You could then extract the ARN and use it when calling Unsubscribe
.
Upvotes: 1