Closed ReniDelonzek closed 3 years ago
displayNotificationWith( )
has property called web it takes WebNotificationDetails
you can use it to display with icon
default is /icons/icon-192.png
but if you need to change the incomming notification from fcm you have to change it in service worker see this
I followed the code indicated, but my app icon is still not displayed in the notification, am I missing something?
const messaging = firebase.messaging();
messaging.setBackgroundMessageHandler(function (payload) {
console.log('[firebase-messaging-sw.js] Received background message ', payload);
// Customize notification here
const notificationOptions = {
body: payload.body,
icon: 'icons/Icon-192.png'
};
return self.registration.showNotification(payload.notificationTitle,
notificationOptions);
});
Found the problem, the indicated documentation is out of date, the method is now onBackgroundMessage
...
const messaging = firebase.messaging();
messaging.onBackgroundMessage(function (payload) {
const notificationOptions = {
body: payload.notification.body,
icon: '/icons/Icon-192.png'
};
return self.registration.showNotification(payload.notification.title,
notificationOptions);
});
That worked for me. Thanks!
I didn't find anything in the documentation, and looking at the code it doesn't seem to be implemented, but I'd like to confirm this/request the feature