Push Notifications

Send data from your server to your users.

Push notifications live at the core of Electrolytic. In fact, it was the primary motivation for us to build Electrolytic because we could not find any reliable and easy-to-use solution anywhere.

Push works similar to how you may have already used in Firebase/FCM or iOS push notifications. Here's a super-simple overview:

  1. A user John starts your app which is using Electrolytic's SDK in it.
  2. SDK provides a unique token to your app.
  3. Your app sends that token to your server.
  4. Your server stores that token against John's record in database.
  5. A few minutes later, your server needs to notify John about a comment on his post.
  6. Your server calls our /push/send endpoint and requests to deliver a payload to that token.
  7. Electrolytic notifies your app.
  8. Your app shows an alert based on the payload it received in the notification.

Once you have installed the package, you can start to listen on the token event emitted by the electrolytic instance.

electrolytic.on('token', (token) => {
  console.log('got a token', token)

A new token is generated on app's launch and also when the app reconnects to the Electrolytic's servers due to any network issues, etc. So it is very important that you listen to this event and report the token to your servers everytime it's provided.

electrolytic.on('push', (payload) => {
  console.log('got a push', payload)

When a push notification is sent via the server or from the dashboard, the SDK will emit push event. The payload sent via push will be provided as-is.

For any issues, suggestions or questions regarding the docs, please use this repo.