Skip to content

Instantly share code, notes, and snippets.

@Emilios1995
Created June 7, 2017 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Emilios1995/7914b8ff2eee073544edff54d906d9ee to your computer and use it in GitHub Desktop.
Save Emilios1995/7914b8ff2eee073544edff54d906d9ee to your computer and use it in GitHub Desktop.
sendNotification = function(data) {
var headers = {
"Content-Type": "application/json; charset=utf-8",
Authorization: "Basic NzkwODdjM2YtODMxNi00ODMyLTgwMWEtZTVkOTcyMzg4ZWRi"
};
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: "b145b13a-567b-4234-a5e1-ea7dd9de7151",
included_segments: ["All"],
contents: { en: "English Message" },
data: { metadataId: "iph", pageId: "informes" }
};
sendNotification(message);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment