fixed TM-171 jira task
This commit is contained in:
@@ -12,3 +12,27 @@ firebase.initializeApp({
|
||||
});
|
||||
|
||||
const messaging = firebase.messaging();
|
||||
|
||||
// Handle background messages
|
||||
messaging.onBackgroundMessage(async (payload) => {
|
||||
|
||||
const notificationTitle = payload.notification.title;
|
||||
const notificationOptions = {
|
||||
body: payload.notification.body,
|
||||
badge: '/icons/Icon-192.svg',
|
||||
icon: '/icons/notification.svg',
|
||||
data: payload.data,
|
||||
click_action: payload.notification.click_action,
|
||||
};
|
||||
|
||||
self.registration.showNotification(notificationTitle, notificationOptions);
|
||||
});
|
||||
|
||||
// Open or focus the app when a notification is clicked
|
||||
self.addEventListener('notificationclick', (event) => {
|
||||
event.notification.close();
|
||||
const targetUrl = 'https://app.opplens.com/notification';
|
||||
event.waitUntil(
|
||||
self.clients.openWindow(targetUrl)
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user