Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to receive an Amazon SNS message on a JS script?

Tags:

I know some options using ruby on rails and/or node.js and PubNuB, a service that has many APIs so you can send/receive notifications between (almost) any platform.

I now how to send messages from PHP and how to receive them there using Amazon SNS, but how can I receive a push notification (a SNS message) on a JS/jQuery script?

Thanks.

like image 527
tvdias Avatar asked Mar 08 '12 20:03

tvdias


People also ask

Can you use SNS without SQS?

SNS supports several end points such as email, SMS, HTTP end point and SQS. If you want unknown number and type of subscribers to receive messages, you need SNS. You don't have to couple SNS and SQS always. You can have SNS send messages to email, SMS or HTTP end point apart from SQS.

How do I use Amazon SNS to send SMS in Java?

If you want to send a SMS message to a single number you can use the Amazon AWS SDK. Docs are available at http://docs.aws.amazon.com/sns/latest/dg/sms_publish-to-phone.html#sms_publish_sdk.

Can SQS trigger SNS?

You can subscribe one or more Amazon SQS queues to an Amazon Simple Notification Service (Amazon SNS) topic. When you publish a message to a topic, Amazon SNS sends the message to each of the subscribed queues.


1 Answers

Yes, but not directly and you'll have to poll for messages on a timer...

In the Product Details page under the heading "Flexible", you'll see that none of the currently supported formats/transports can be hosted in the browser.

However... Amazon SQS is one of the supported transports, and it in turn can be accessed from JavaScript - see an example app here: http://aws.amazon.com/code/Amazon-SQS/1254. (The example shows JavaScript accessing SQS).

You'd have to manually poll though, as there is no "push" to the browser with SQS.

(Alternatively, you could do it all server-side, and then you could use potentially use websockets to push the messages to the browser.)

like image 102
Steve Campbell Avatar answered Sep 20 '22 17:09

Steve Campbell