答案 0 :(得分:0)
找到答案!!
//This function to sends push notification to users
for (var i = 0; i <= endUsersList.length - 1; i++)
{
fetch('https://fcm.googleapis.com/fcm/send', {
'method': 'POST',
'headers': {
'Authorization': 'key=' + key,
'Content-Type': 'application/json'
},
'body': JSON.stringify({
'notification': notification,
'to': endUsersList[i]
}),
}).then(function (response) {
if (response.status !== 200) {
console.log('Looks like there was a problem. Status Code: ' +
response.status);
return;
}
// Examine the text in the response
response.json().then(function (data) {
console.log(data);
});
}).catch(function (err) {
console.log('Fetch Error :-S', err);
})