quickstart-js icon indicating copy to clipboard operation
quickstart-js copied to clipboard

Icon not displayed for background messages

Open bartslootweg opened this issue 9 years ago • 2 comments

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?

bartslootweg avatar May 11 '17 14:05 bartslootweg

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}

sidyyy911 avatar May 12 '17 12:05 sidyyy911

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.

gauntface avatar May 30 '17 20:05 gauntface