October 2017
Intermediate to advanced
302 pages
7h 27m
English
The service we will use to send push notifications to user devices is called Firebase Cloud Messaging, or FCM. FCM works on the web by looking for a service worker and then sending it a message (containing the notification details). The service worker then displays the notification.
By default, FCM looks for a service worker named firebase-messaging-sw.js. You can change that using firebase.messaging().useServiceWorker and passing a service worker registration object. For our purposes, however, it will be more straightforward to simply rename our service worker. Let's do so; change the filename in public/ and in the registration in index.html:
<script> if ('serviceWorker' in navigator) { window.addEventListener('load', ...Read now
Unlock full access