quickstart-js
quickstart-js copied to clipboard
I want to know how to add an image for the web notification?
I config like this: notification: { image: '' } but doesn't work
@szjSmiling Could you try using webpush -> notification -> image field?
@szjSmiling note that you need to have the message object when sending a message. Eg:
message: {
token: 'token of client receiving the message',
notification: {
title: 'my notification title',
body: 'my notification body',
image: 'url to notification image'
}
}
Using the example in https://github.com/firebase/quickstart-js/tree/master/messaging the following 2 ways of specifying an image work
1) Using a full URL
- As suggested by Arthur above

2) Using a relative URL
- relative to the site where the push is set up

Curl request used from the Readme in that sample code
curl -X POST -H "Authorization: key=YOUR-SERVER-KEY" -H "Content-Type: application/json" -d '{
"notification": {
"title": "Portugal vs. Denmark",
"body": "5 to 1",
"icon": "firebase-logo.png",
"click_action": "http://localhost:8081"
},
"to": "YOUR-IID-TOKEN"
}' "https://fcm.googleapis.com/fcm/send"
Thanks for the detailed info, @thewheat!