Created
June 7, 2017 22:46
-
-
Save Emilios1995/7914b8ff2eee073544edff54d906d9ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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