Batch supports sending push notifications directly to web browsers, on desktop and mobile, even if your website is closed.
Batch relies on two different technologies to deliver push notifications to the browser of your users, on desktop or mobile:
- The Push API W3C standard
- Service Workers
Any browsers implementing both technologies will be compatible with our Web SDK and will be able to receive push notifications: Google Chrome, Mozilla Firefox and any chromium-based browsers (Microsoft Edge, Opera, Vivaldi, etc).
Understanding How Batch Works
Integrating Batch into your website is simple. You must:
- Upload Batch's service worker to the root of your website
All the data collected from the website until users clear site data will be attached to that "installation ID":
Collecting a Token
In order to send a push notification to a device, Batch needs to collect an endpoint. That enpoint is anonymous and delivered by the servers of each browser (e.g. Google, Mozilla, etc).
Here is how Batch collects an endpoint and generates a token:
- If users turn on push notifications, the browser requests an endpoint to the push notification service.
- The push notification service then generates a public endpoint and sends it to the browser.
Batch servers store that endpoint for the install and generate a "token". That token contains:
- An endpoint: the anonymous id generated by the push notification service for the browser (endpoint)
- The public key of the user's browser that allows it to decode the notification Batch will send (p256dh). The browser of every subscribers has a different public key.
- A secret key (auth).
Here is how a token looks like:
Sending a Push Notification
Here is how Batch sends push notifications to your users:
- First, Batch encodes the content of the notification for every subscribed browser, based in the public key. The message sent from Batch can only be decoded by your user's browser.
- Batch servers send the notification over HTTPS to the push notification service, signing the requests using a "private VAPID key" known exclusively by Batch.
- Then the push notification service only reads the header to know which endpoint should be targeted. It cannot decode the message. The push notification service will also check if Batch is allowed to push that browser based on the private VAPID key and check if the endpoint is still valid (e.g. in case users cleared site data or uninstalled the browser).
- Finally, the browser receives the push notification. Batch service worker decodes it and displays it.
Batch uses the feedback received from the push service to delete tokens that may be invalid in your userbase. Batch service worker will also send feedback to Batch servers when users click the notification. You can find both information in your campaign reports.