I'm receiving firebase notifications and I want to display them as a pop up notification in background (when user is on different tab).
In my firebase-messaging-sw.js I have tried with two different methonds, both of them are console.log() the payload, and that's okay, but there is no notification pop up in the background.
messaging.setBackgroundMessageHandler(function(payload) {
console.log('[firebase-messaging-sw.js] Received background message ', payload);
// Customize notification here
const notificationTitle = 'Background Message Title';
const notificationOptions = {
body : 'Background Message body.',
icon : '/firebase-logo.png'
};
return self.registration.showNotification(notificationTitle,
notificationOptions);
});
and
messaging.onBackgroundMessage((payload) => {
console.log('[firebase-messaging-sw.js] Received background message ', payload);
// Customize notification here
const notificationTitle = 'Background Message Title';
const notificationOptions = {
body: 'Background Message body.',
icon: '/firebase-logo.png'
};
self.registration.showNotification(notificationTitle,
notificationOptions);
});
I have tried also to downgrade firebase, but no success. So, how can I display pop up ?