How to programmatically delete confirmed SNS subscription (but not the topic) using Java SDK? - amazon-sqs

I'm writing an application that programmatically creates a new SQS queue that subscribes to an existing SNS topic and then deletes the SQS queue after.
I know there's a way to delete the SNS topic along with its subscriptions using Java SDK. I know I can manually delete the confirmed subscriptions from the web console. I know that pending subscriptions will expire on their own.
But I'd like to delete confirmed subscriptions programmatically but keep the SNS topic. Or will my confirmed subscription expire after some time after the SQS queue is gone?

To delete a subscriber to an Amazon SNS topic using the Java SDK, you should use the unsubscribe() command.
default UnsubscribeResponse unsubscribe(Consumer<UnsubscribeRequest.Builder> unsubscribeRequest)
throws InvalidParameterException,
InternalErrorException,
AuthorizationErrorException,
NotFoundException,
InvalidSecurityException,
AwsServiceException,
SdkClientException,
SnsException
Deletes a subscription. If the subscription requires authentication for deletion, only the owner of the subscription or the topic's owner can unsubscribe, and an AWS signature is required. If the Unsubscribe call does not require authentication and the requester is not the subscription owner, a final cancellation message is delivered to the endpoint, so that the endpoint owner can easily resubscribe to the topic if the Unsubscribe request was unintended.

Related

O365 Graph Subscriptions - Not receiving notifications for subscriptions on user mailfolder updates and deletes

I am attempting to use the microsoft graph api to setup a subscription for a user's mailfolders for the changeType of updated, deleted with the resource of /me/mailfolders (synonymous with /users/{id}/mailfolders. The subscription creates successfully, but when i move folders around in the outlook client, or delete folders, no notifications are received on my notification client.
Am asking this stackoverflow question as per troubleshooting instructions in Microsoft's guide.
Wondering if this is a supported resource? And if so, why no notifications are being received?
Subscription ID: 78b8a9a5-083e-427d-b7e0-95c0f5cffdda
According the documentation you cannot create subscription for mail folder but only for changes to all messages in a user's mailbox or for changes to messages in a user's Inbox.
/me/messages
/users/{id}/messages
/me/mailFolders('inbox')/messages
/users/{id}/mailFolders('inbox')/messages

how to listen to response from a webhook?

I am implementing webhooks with my payment solution (stripe), and I set up basic webhook server responses.
So, upon various events, such as updating a subscription, a server request is sent to a specific endpoint (/webhooks), and a 200 response is fired.
Now, I would like to listen to this server with my saga, but I'm not sure how to do that. The idea is I have a redux-saga event channel listening, and such an async request as updating a subscription status, would trigger a new saga. If for instance, the user updated his subscription status from paid to unpaid, his new status could reflect immediately in the UI.
Implementing this is not an issue when the event is triggered by the user. However, stripe allows me (as an admin) to trigger such events from Stripe's dashboard. If let's say I update one user's subscription status from Stripe's dashboard (because there is a bug with the UI for example), that will send a request to the webhooks endpoint on my server, but I'm not sure how to "intercept" it on the front-end, in order to then do what's needed for that user.
Do you have any suggestion ? I read about service workers, about pub/sub services. But I'm not sure they are the right way to do what i'm trying to do.
You'd need to implement either websockets or long polling from your frontend to your backend that looks for the updated response/data in your backend.

Billing.subscription.renewed webhook is not being triggered

So I'm trying to know which paypal webhook is being sent when the user successfully paid for another billing cycle.
I have a daily subscription plan right now the user was successfully charged but the Billing.subscription.renewed webhook was not triggered
My question is which webhook is sent when a the customer pays for the new billing cycle on paypal
No BILLING.SUBSCRIPTION.RENEWED webhook exists; subscriptions do not need to be renewed and have either a fixed or unlimited duration. You can find an actual list of all existing webhooks here: https://developer.paypal.com/docs/integration/direct/webhooks/event-names/#subscriptions . The list is current.
When there is a payment made on a subscription, the event name is PAYMENT.SALE.COMPLETED as described there.

How to achieve twitter like push notification via AWS SNS?

Is there a way to achieve twitter like push notification via AWS SNS?
SNS send notification to the user when something is happen him or her?
As i know the best way is to create a topic per user.
When user relate event happened,we publish a notification to the topic.
As AWS described the max topic number is 100,000 per account currently.
What if i've 1,000,000 users, it will not work.
Is there a more scalable scheme?
beeth0ven,
SNS supports publishing to a Topic of subscribed device endpoints or direct publishing to individual endpoints. In your case, you'll want to implement direct publishing to each individual endpoint. This allows more control and personal engagement but also means that you'll need to manage those endpoints in your own database and associate each endpoint to a user of your mobile app. Instead of publishing to a TopicArn, you'll publish individual messages to a TargetArn, which is the SNS Platform Endpoint that represents an app and mobile device. TargetArn is also the same call to send an SMS message to an individual phone number.
SNS Publish CLI: (see --target-arn)
http://docs.aws.amazon.com/cli/latest/reference/sns/publish.html
Direct Publishing via the Console:
http://docs.aws.amazon.com/sns/latest/dg/mobile-push-send-directmobile.html

Amazon SNS Mobile Push - how to bulk subscribe endpoints to a topic?

I am trying to move my existing iOS push notification infrastructure over to amazon SNS mobile push.
I exported all my tokens from my local db into an SNS application (using CSV). Now I want to send push notification to all my 10,000 users. I think the only way is to create a topic and subscribe all the users to that topic then publish message to that topic.
Is there any easy way to subscribe all the 10,000 users who I have imported into the system to a topic?
Thanks for any help!
It sounds like you have created the Amazon SNS Platform Application and imported your tokens as Amazon SNS Platform Endpoints.
What kind of notification are you sending?
If you send a custom message to each user, use Direct
Addressing. With this approach, you
Publish to each EndpointARN.
If you send the same message to all users, use topics. You need to subscribe your endpoints to a topic. When you are ready to send, Publish to the TopicARN. Amazon SNS will handle delivery to all endpoints subscribed to that topic. Amazon SNS currently does not provide a bulk subscribe API, so you will have to invoke Subscribe once per EndpointARN.
Full disclosure: I work for AWS on Amazon SNS.
Unfortunately there is no way so far... see Bulk push endpoints subscription to a topic on AWS Discussion Forum.
Hi there langelvicente,
Thanks for this feature request. I've passed this back through to the SNS Service Team for review.
Best regards,
Phil P
This is now possible with subscribing mobile endpoints to topics. The default subscriber limit was increased.
Q: Are there limits to the number of topics or number of subscribers
per topic?
By default, SNS offers 10 million subscriptions per topic, and 3,000
topics per account. To request a higher limit, please contact us at
at http://aws.amazon.com/support
http://aws.amazon.com/sns/faqs/?nc2=h_ls
If you have an application full of endpoints which you want to bulk subscribe to a SNS topic you can do so from the AWS SNS dashboard by:
Going to that application in SNS
Waiting until the 'total items' count at the bottom has completed its count (ie all items are listed)
Checking the select all check mark above the list of endpoints (screenshot attached)
Tap on platform action > subscribe endpoints to topic
Enter your topic ARN and click create subscription
The process will begin and it will stall your web browser but let it be as it takes time and if you want to see the subscriptions to the topic increasing you can use the AWS CLI with :
aws sns get-topic-attributes --topic-arn "[YOUR TOPIC ARN]"
note the "SubscriptionsConfirmed" value
Yes, but caveat: they each must accept your effort to enroll them into push messaging. That means that for each token in your database, each individual must consent to receiving future messages from you (via SMS and email, that is).
Each address (tel #, email) becomes an endpoint, and you can use SNS to create a topic, then subscribe each endpoint. After a confirmation email is sent to each endpoint (person on your list), they must confirm, in order to begin receiving your stream of messages via text or email.
Unfortunately, this confirmation/consent event is dicey, and must be handled correctly. Your ARN's title must be succinct (7 letter via SMS, no subject line allowed). Hence, you must contact them via SMS using a name they will recognize (the SMS message will arrive via short code, 304-something), and can be refused and/or blocked.
Not trivial! Best to investigate using push messages via mobile app. This will avoid the coveted SMS space, but you might consider putting out a blast to email and/or SMS, in order to get them using your mobile app. Apparently, given the immediacy of SMS, folks will be reading your first confirmation within 20 seconds. This could be a good thing, if they confirm, then accept your future messages.
Am doing this right now, and am preparing to be recognized by name using my initial blast -- apps that create anonymous SMS will be banned through iTunes!

Resources