23

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.

Arafat Nalkhande
  • 11,078
  • 9
  • 39
  • 63
tvdias
  • 821
  • 2
  • 10
  • 25

2 Answers2

18

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.)

acjay
  • 34,571
  • 6
  • 57
  • 100
Steve Campbell
  • 3,385
  • 1
  • 31
  • 43
  • 3
    Is it possible that AWS SNS still does not support websockets?! – Draško Kokić Oct 21 '15 at 15:58
  • 1
    @DraškoKokić, it is unlikely that SNS will ever directly support WebSockets. WebSockets require a long-lived connection. SNS caters for Push notifications. – Jason Feb 28 '16 at 04:48
0

Use a service worker in your project and set up a Push Notification handler... I created a GCM project and made a little node.js server and it seems to receive messages from SNS... No polling required.

StratusBase LLC
  • 289
  • 1
  • 5
  • 16