Amazon MWS Push Notifications - amazon-web-services

I want to develop an app that allows the users of the app (sellers on Amazon), to send me a notification when they receive an order on Amazon (a notification containing informations about the order).
Is it possible?
Maybe only the seller can receive notifications about his account.
I think, if it's possible, I need a MWS and a AWS account.
In the documentation of MWS (https://docs.developer.amazonservices.com/en_US/notifications/Notifications_Overview.html), there is:
The Amazon MWS push notifications enable you to receive information
that is relevant to your business with Amazon without having to poll
the Amazon MWS service. Instead, the information is sent directly to
you when an event occurs to which you are subscribed. For more
information about how to subscribe to receive notifications, see
Subscriptions Overview in the Amazon MWS Subscriptions API section
reference.
Then, in the 'Subscriptions API' section:
The Amazon MWS Subscriptions API section enables you to subscribe to
receive notifications that are relevant to your business with Amazon.
With the operations in the Subscriptions API section, you can register
to receive important information from Amazon without having to poll
the Amazon MWS service. Instead, the information is sent directly to
you when an event occurs to which you are subscribed.
To receive notifications, you must first create and register a
Destination, such as an Amazon Simple Queue Service (Amazon SQS)
queue. Then, you create a Subscription for the NotificationType that
you want to receive, such as a notification when another Seller has
changed their offer for an item that you also sell. Finally, verify
that Amazon is able to send notifications to your Destination by
calling the SendTestNotificationToDestination operation.

Not at this time. The only notification options are AnyOfferChangedNotification, which sends an SQS message when any one of the top 20 offers for an ASIN changes, and FulfillmentOrderStatusNotification, which notifies you if there is a multi channel order status chance, and FeePromotionNotification.
This hasn't changed since I started using the AnyOfferChangedNotification several years ago.
One idea is to create an app that uses the Orders API periodically to check for orders, then you can have the app create the SQS message (or use another service altogether). This would then notify you of a new order.

Related

Difference between a device subscribing to an SNS topic, and a lambda function subscribing to a topic?

Im currently trying to design a scalable push notification service, which can send notifications to 5-10 mil users in a very short time. I came across two AWS related architectures which got me confused.
Use case: Send a notification to all the users.
1) Each device subscribes to an SNS topic, and if we want to send a push to all users, we just publish to the topics endpoint. And SNS handles the rest(sending to the million users)
2) Lambda functions are subscribed to SNS topics. We send a message to an SNS topic containing all the device tokens/batches, and then lambda calls APN/Firebase endpoints.
I fail to see in what case the second architecture would be beneficial compared to the first?
Mobile push notification :
sns endpoint will created based on user device token and you will get device token from Adm,Fcm,etc like push notification platform sdk and you can trigger push notification to perticular user based sns endpoint because each device have different endpoint and it created user device token and you will have track user device token and endpoint and userId and you can able to see aws sns mobile push notification console
1) you can create manually also
2) you can create endpoint using programmatically
you can refer below sdks to create via code https://docs.aws.amazon.com/sns/latest/dg/mobile-push-api.html
Lamda push notification
You can create sns topic in sns console and you can subscribe which lambda you want deliver notification
basically if you want connect one lamda to another lamda you can use those case
example 1:
you have micro service for sending otp to user and micro service deployed in different lambda and application recives sending otp request your application main lamda and now you need call otpservice lamda so you can create one sns topic and under subscription you can subscripe otp micro service lamda so main lamda will trigger otp service sns endpoint it will deliver notification micro service lamda

How to send notifications to a specific user with AWS SNS?

I am developing an app like Dominoes. In which, I would like to send a Push notification to the Customer, when his/her Order is prepared.
I had been using OneSignal to do so (through sending notification to a particular player id), and now we would like to do it with AWS SNS Service, as we are using bunch of different AWS Services too.
We don't want any marketing/bulk push notifications, the SNS Service would do only one thing - send a particular message from the Restaurants' Mobile (using REST API), and it would reach the Customer's mobile.
With OneSignal, we used to give the PlayerID/UserID of the receiver. Does this method apply to AWS SNS too? Also, we could only work with HTTPS POST requests in our platform.
Any help is appreciated :)
Thanks!

AWS Mobile Push with users that may be logged into multiple devices

Our apps are being developed for both Android and iOS. We are using AWS SNS Mobile Push to push messages to both GCM and APNS. The back end is PHP and so it uses the AWS PHP SDK.
Until now, our system has been saving 1 Endpoint ARN per user. We then broadcast a Mobile Push message directly to this Endpoint ARN.
The question:
It would be strange if a user were logged into our app on multiple devices and did not receive push notifications on all of them. So - we're going to have to change something.
How, in AWS Mobile Push, is the concept of 'one user, multiple devices (and potentially multiple platforms) handled?
Does our system have to maintain a one-to-many association of user-to-EndpointARNs (i.e. start saving multiple EndpointARNs per user so that we may push messages to all of them sequentially)?
Or should I be looking into the 'Topics' concept that Mobile Push provides (I'm confused here - do some people use one topic per user, and then push messages to the topic itself?)..
Lastly - I guess as a bonus question - is it normal for people using the PHP AWS SDK to include both APNS and GCM attributes in the Message payload array? We haven't been keeping track of 'which type of device each user uses'. We've just been saving an Endpoint ARN per user. And I guess the thought was to just cover all our platform bases (APNS, APNS_SANDBOX, GCM) when we're pushing a message to an endpoint.
I've been doing a lot of searching on the 'one user with multiple devices' topic re: Mobile Push with AWS SNS, and really the results have been quite unhelpful.
Help please :(
Thanks!
Once you send SNS Push message , you will get success or failure reason.
Could you please check your logs and share to identify exact issue.
Cloudwatch :
SNS publishes Cloudwatch metrics for number of messages published, number of successful notifications, number of failed notifications and size of data published. Metrics are available on per application basis. You can access Cloudwatch metrics via AWS Management Console or CloudWatch APIs.
Direct addressing:
Direct addressing allows you to deliver notifications directly to a single endpoint, rather than sending identical messages to all subscribers of a topic. This is useful if you want to deliver precisely targeted messages to each recipient. When you register device tokens with SNS, SNS creates an endpoint that corresponds to the token. You can publish to the token endpoint just as you would publish to a topic. You can direct publish either the text of your notification, or a platform-specific payload that takes advantage of platform-specific features such as updating the badge count of your app. Direct addressing is currently only available for push notifications endpoints.
Official documentation, "When a topic is created, Amazon SNS will assign a unique ARN (Amazon Resource Name) to the topic.
https://aws.amazon.com/sns/faqs/
I have a solution for this issue as you already know ARN is associated with single device token so you must be manage it own your own to send push to same user with multiple device.
My approach is to create 2 table in mysql or whatever database you are using
1. For APNS or, APNS_SANDBOX having details like user_id(local), device token, endpoint ARN, status etc (EG : sns_apns)
2. Same for GCM or BAIDU you have to create a table having user details with endpoint ARN(EG : sns_gcm)
Now every time when you send push to a particular user just write a code something like this
Switch($platform) {
case 'APNS':
case 'APNS_SANDBOX':
Select all users from sns_apns by login id.
Create a message and send it to all users having same user id
case 'GCM':
Select all users from sns_gcm by login id.
Create a message and send it to all users having same user id
}
I haven't tried this but to solve your problem I would keep a map of the user's cognito userID and corresponding endpoint ARN for each major app defining transaction done by the user. If the endpoint already exist then no need to save it. But if for this userID another endpoint ARN is notice then save, update, add or associate this new endpointARN with userID in DynamoDB as a #Document attribute. Then at anytime just broadcast to all endpointARN associated to the userID in DynamoDB.
The mysampleapp mobile hub example codes are useful for quick manipulation. For android:
Get the endpointARN in app like this:
PushManager pushManager;
String userDeviceEndPoint;
pushManager = AWSMobileClient.defaultMobileClient().getPushManager();
userDeviceEndPoint = pushManager.getEndpointArn();
You can update DynamoDB using the update save behaviour to ignore if an already existing endpoint is noticed for the user:
DynamoDBMapper mapper = new DynamoDBMapper(ddbClient, new DynamoDBMapperConfig(DynamoDBMapperConfig.SaveBehavior.UPDATE_SKIP_NULL_ATTRIBUTES));
Not sure how to do this in PHP though. Hope this idea helps.

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.

SNS Batch Publish

I see AWS publish API for sending push notifications to devices.
http://docs.aws.amazon.com/sns/latest/api/API_Publish.html
According to:
https://aws.amazon.com/blogs/aws/push-notifications-to-mobile-devices-using-amazon-sns/
We can
"Send messages directly to a specific device by calling the Publish function with the device’s ARN. You can easily scale this to handle millions of users by storing the endpoint ARNs in Amazon DynamoDB and using multi-threaded code on the server."
If I want to send push notifs to 100K users (who haven't registered to a specific topic), is there a multi-publish (or batch-publish) API, where I don't need to call the "Push notifications" API for every single user?
probably not. the devices need to be registered (i.e. for SNS you actually have to create the endpoint for each device).
After you have the endpoint you can subscribe them to either one or multiple SNS endpoint and start publishing notifications through them.