【发布时间】:2018-08-27 17:38:28
【问题描述】:
我正在关注this tutorial,到目前为止,我的通知适用于网络浏览器(在 chrome 中测试)
但我不知道如何通过有效负载发送图标,到目前为止我所做的是发送请求的正文如下(我正在使用firebase云功能):
{
'message': {
token,
'notification': {
title,
body,
icon // <-- added the icon
}
}
}
如果我尝试在消息负载中添加图标,我在向 google FCM URL 发布帖子时收到错误请求。
它可以在不将图标属性添加到有效负载的情况下工作,显然,这是错误,问题再次是如何将有效负载中的图标发送到工作。
谢谢
编辑,我正在发布我的帖子功能:
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;
}
【问题讨论】:
标签: node.js firebase google-cloud-functions