Created
December 13, 2022 12:40
-
-
Save aangindra/c5197a45ad3325cb74f36bdfb541c87f to your computer and use it in GitHub Desktop.
Firebase Messaging 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
importScripts('https://www.gstatic.com/firebasejs/8.2.6/firebase-app.js'); | |
importScripts('https://www.gstatic.com/firebasejs/8.2.6/firebase-messaging.js'); | |
// Initialize the Firebase app in the service worker by passing in | |
// your app's Firebase config object. | |
// https://firebase.google.com/docs/web/setup#config-object | |
const firebaseApp = firebase.initializeApp({ | |
apiKey: 'AIzaSyAAWS9ujRFQ17a2aZqUiP5Vdg6pTbe5D00', | |
authDomain: 'okgaminggroup.firebaseapp.com', | |
projectId: 'okgaminggroup', | |
storageBucket: 'okgaminggroup.appspot.com', | |
messagingSenderId: '551628956751', | |
appId: '1:551628956751:web:90ae8e0817f1c869f5f63a', | |
measurementId: 'G-004L4X73S5', | |
}); | |
// Retrieve an instance of Firebase Messaging so that it can handle background | |
// messages. | |
const messaging = firebase.messaging(firebaseApp); | |
messaging.onBackgroundMessage((payload) => { | |
// console.log('[firebase-messaging-sw.js] Received background message ', payload); | |
// Customize notification here | |
const { notification } = payload; | |
self.registration.showNotification(notification.title, notification.body); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment