【发布时间】:2019-02-26 08:15:21
【问题描述】:
我正在尝试从 NodeJS 后端按照文档 (https://firebase.google.com/docs/cloud-messaging/js/device-group) 中的说明创建设备组,但我做不到,我总是遇到 400 错误
有人知道我做错了什么吗?
const httpRequest = require('request');
const options = {
url: 'https://fcm.googleapis.com/fcm/notification',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'key=AAA...vR',
'project_id': '76...8'
},
body: JSON.stringify({
operation: 'create',
notification_key_name: 'my-unique-key-name',
registration_ids: ['token1', 'token2']
})
};
httpRequest(options, (error, response, body) => {
if (!error && response.statusCode === 200) {
resolve(Converter.parseJSON(body));
} else {
reject(error);
}
});
提前感谢任何提示或帮助!
【问题讨论】:
标签: node.js firebase http-post firebase-cloud-messaging firebase-notifications