Web Push Notifications
  • Integration
    • My website already has a service worker
    • My website does not have a service worker
    • Salesforce Commerce Cloud
  • Defining Notifications
    • Image sizing
  • Dashboard
  • Settings
  • Troubleshooting
Powered by GitBook
On this page
  • Requirements
  • Guide
  1. Integration

My website already has a service worker

Requirements

  1. Your existing service worker must be served from the root of your webserver or use the Service-Worker-Allowed header technique described in the Troubleshooting section.

Guide

1. Include the following inside your existing JavaScript service worker:

var fanplayrOptions = {
  version: 1,
  // When `true`, Fanplayr will add "install" and "activate" event handlers
  // to the Service Worker which will cause it to be installed and activated
  // immediately without waiting for any caches to load.
  // Set to `false` if your Service Worker implements either of these events.
  immediate: true
};
importScripts('https://static.fanplayr.com/client/sw.js?v=' + fanplayrOptions.version);

2. Include the following HTML on all pages of your website:

<script>
window.fanplayrServiceWorker = true;
</script>
PreviousIntegrationNextMy website does not have a service worker

Last updated 3 years ago