Last active
March 25, 2024 09:39
-
-
Save benixal/80440dcec49f71c4423f428e27e7ad6f to your computer and use it in GitHub Desktop.
Firebase Cloud Messaging (FCM) custom service worker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.addEventListener("push", (event) => { | |
const notif = event.data.json().notification; | |
event.waitUntil(self.registration.showNotification(notif.title, { | |
body: notif.body, | |
icon: notif.image, /* or "icon.png" */ | |
data: { | |
url: notif.click_action | |
} | |
})) | |
}) | |
self.addEventListener("notificationclick",(event) => { | |
event.waitUntil(clients.openWindow(event.notification.data.url)) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment