Search code examples
javascriptparse-platformpushparse-server

How to Receive Push Notification on website using Parse JS SDK?


I have configured push notifications on Parse-Server & in Android app. But I am not able receive push notifications in a website using Parse JS SDK. They don't provide any method to subscribe for push notifications in ther JS APIs. There Documentation (JS) only talks about subscribing to mobile devices not browsers.

SUBSCRIBING TO CHANNELS

The JavaScript SDK does not currently support subscribing iOS and Android devices for pushes. Take a look at the iOS, Android or REST Push guide using the platform toggle at the top.

So, I concluded that web browsers can't subscribe just by using Parse JS SDK? So, how should I subscribe & receive Push notifications on a web browser from Parse Backend?

Update:

I haven't test but If I use ServiceWorker to get subscription & subscribe user to some channel, can I use the default Parse Class Installation for saving subscription & then use that (web) Installation in Cloud Code to send Push?


Solution

  • I have tested it and got achieved desired results via following. As Jake said, for web there are no Installations in Parse. So, in order to receive push notifications on the web, you have to

    1. Register a Service worker to get pushSubscription and hande push, click events etc.
    2. Save pushSubscription to server. It will be used to send pushes to Web.
    3. Integrate Push notifications on Parse-Server (FCM etc) or web-push if you want.
    4. Send push via Client SDK or Cloud Code, it must be received.

    Further, the Installation class cannot be used for web pushes.