【发布时间】:2017-01-07 14:43:39
【问题描述】:
如何在节点 js 中创建推送通知时包含小图标和大图标 url,我知道我们需要在发送推送通知时发送图像 url,我需要节点 js 中的代码示例..我有这个代码..
sendNotificationToSpecific =function (token,messages) {
var sendNotification = function (data) {
var headers = {
"Content-Type": "application/json; charset=utf-8",
"Authorization": "Basic MDNlMTNjYWMTgy"
};
var options = {
host: "onesignal.com",
port: 443,
path: "/api/v1/notifications",
method: "POST",
headers: headers
};
var https = require('https');
var req = https.request(options, function (res) {
res.on('data', function (data) {
console.log("Response:");
console.log(JSON.parse(data));
});
});
req.on('error', function (e) {
console.log("ERROR:");
console.log(e);
});
req.write(JSON.stringify(data));
req.end();
};
var message = {
app_id: "awer342-d744-4787-b59a-f55c6215c491",
contents: {"en": messages},
include_player_ids: [token],
};
sendNotification(message);
};
【问题讨论】:
-
你用什么插件?
-
我没有使用任何插件
-
我正在尝试这样做,但是无法发送通知,stackoverflow.com/questions/44491033/…,你可以检查一下吗?
-
你能帮帮我吗?
标签: node.js push-notification onesignal