step 1 api
This commit is contained in:
1 parent
32b1347223
commit
13b17037c9
20 files changed
+1997
-143
No files matched your search
@@ -0,0 +1,43 @@
|
||||
// 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.
|
||||
// Replace 10.13.2 with latest version of the Firebase JS SDK.
|
||||
importScripts('https://www.gstatic.com/firebasejs/10.13.2/firebase-app-compat.js');
|
||||
importScripts('https://www.gstatic.com/firebasejs/10.13.2/firebase-messaging-compat.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
|
||||
firebase.initializeApp({
|
||||
apiKey: "AIzaSyC14hS0_idUIRS9JEigObmT-_CGl3zb8Fo",
|
||||
authDomain: "thirukalyanam-c8e1c.firebaseapp.com",
|
||||
projectId: "thirukalyanam-c8e1c",
|
||||
storageBucket: "thirukalyanam-c8e1c.firebasestorage.app",
|
||||
messagingSenderId: "433615056618",
|
||||
appId: "1:433615056618:web:309a920f408ba826907193",
|
||||
measurementId: "G-1L93F6DS7K"
|
||||
});
|
||||
|
||||
// Retrieve an instance of Firebase Messaging so that it can handle background
|
||||
// messages.
|
||||
const messaging = firebase.messaging();
|
||||
|
||||
|
||||
|
||||
messaging.onBackgroundMessage((payload) => {
|
||||
console.log(
|
||||
'[firebase-messaging-sw.js] Received background message ',
|
||||
payload
|
||||
);
|
||||
// Customize notification here
|
||||
const notificationTitle = payload.notification.title;
|
||||
const notificationOptions = {
|
||||
body: payload.notification.body,
|
||||
icon: payload.notification.image || "/favicon.ico",
|
||||
data: {
|
||||
url: "/notification" // 👈 set target URL
|
||||
}
|
||||
};
|
||||
|
||||
self.registration.showNotification(notificationTitle, notificationOptions);
|
||||
});
|
||||
Reference in new issue
Block a user