【发布时间】:2014-03-06 04:54:42
【问题描述】:
我在向 Google Cloud Messaging by Node 应用程序发送消息时遇到问题。我已创建 API 密钥(服务器和浏览器),已将服务器密钥服务器 IP 和代码列入白名单
var headers = [
'Content-Type: application/json',
'Authorization: key=' + apiKey
];
curl("https://android.googleapis.com/gcm/send", {
HTTPHEADER: headers,
POST: true,
POSTFIELDS: JSON.stringify({
data: {
type: 'xxx',
city: 'xxx',
url: 'xxx'
},
registration_ids: [phoneId]
})
}, function () {
console.log(arguments);
});
我正在尝试向 Android 设备发送简单的通知。不幸的是,我收到 401 Unauthorized 错误。我正在使用node-curl 库,之前我尝试过node-gcm 和node-gcm-service - 两者的结果相同。有没有我错过的可能性?
提前感谢您的帮助, 大卫。
【问题讨论】:
标签: android node.js curl google-cloud-messaging