Icon not displayed for background messages
Hi,
When using messages when app is in foreground (new Notification()) the custom icon is working fine. However when I receive a notification in the background, the icon never works. No matter where I place it. Next to the service worker, or in the root of the web address. This is how it is currently set:
const notificationOptions = { body: payload.data.message, icon: '/firebase-logo.png' };
return self.registration.showNotification(notificationTitle, notificationOptions);
What am I doing wrong?
Background messages are handled by the serviceWorker which is standalone. For background messages your webapp is not in context so a relative url will not work. Try giving a webURL. A static link to where your webapp is deployed could work in your case. e.g http://www.{mywebapp}.com/{imgURI}
You might want to look in the network panel to see what URL's are being attempted and find the full URL for the image and if it's failing, then try manually loading the image in the browser, if that's failing then something is incorrect, either the path or the server setup.
Please provide an example that demonstrates the issue for further support.