I'm following this tutorial, so far I have notifications working for web browsers (tested in chrome)
But I don't know how to send the icon via payload, so far what I've done is send the body of the request as follows (I'm using firebase cloud functions):
{
'message': {
token,
'notification': {
title,
body,
icon // <-- added the icon
}
}
}
if I try to add the icon in the message payload I get a bad request when I do the post to the google FCM URL.
it works without adding the icon property to the payload, obviously, that's the error, the question again is how to send the icon in the payload to work.
thanks
EDIT, I'm posting my post function:
async function notification(messageBody) {
const api = 'https://fcm.googleapis.com/v1/projects/{projectID}/messages:send';
const accessToken = await getAccessToken();
const response = await fetch(api, {
headers: {
'Accept': 'application/json',
'Content-type': 'application/json',
'Authorization': `Bearer ${accessToken}`
},
method: 'POST',
body: messageBody
});
return response;
}