Skip to content

Instantly share code, notes, and snippets.

View dev-zarghami's full-sized avatar
💫
I Convert Coffee into Code

Artin zarghami dev-zarghami

💫
I Convert Coffee into Code
View GitHub Profile
@dev-zarghami
dev-zarghami / firebase-messaging-sw.js
Created October 29, 2023 16:17 — forked from loicginoux/firebase-messaging-sw.js
Adding FCM to an html page to receive notifications and sending then via FCM ruby gem. (edit: HTTPS needed!)
// [START initialize_firebase_in_sw]
// Give the service worker access to Firebase Messaging.
// Note that you can only use Firebase Messaging here, other Firebase libraries
// are not available in the service worker.
importScripts('https://www.gstatic.com/firebasejs/3.5.2/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/3.5.2/firebase-messaging.js');
// Initialize the Firebase app in the service worker by passing in the
// messagingSenderId.
firebase.initializeApp({