我在跟踪
this tutorial
,到目前为止,我已经有了适用于web浏览器的通知(在chrome中测试)
{
'message': {
token,
'notification': {
title,
body,
icon
}
}
}
如果我试图在消息有效负载中添加图标,那么当我向google FCM URL发送帖子时,会收到一个错误的请求。
它在没有向负载添加icon属性的情况下工作,显然,这就是错误,问题再次是如何发送负载中的图标来工作。
谢谢
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;
}