Skip to content

Instantly share code, notes, and snippets.

@nebiros
Last active January 8, 2019 05:10
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nebiros/9196645 to your computer and use it in GitHub Desktop.
Save nebiros/9196645 to your computer and use it in GitHub Desktop.
Send Push Notifications from node.js with Parse.com SDK
var Parse = require("parse").Parse;
Parse.initialize(
"", // applicationId
"", // javaScriptKey
"" // masterKey
);
var query = new Parse.Query(Parse.Installation)
, data = {
"alert": "A message!",
"anotherObjectId": "", // extra data to send to the phone.
"sound": "cheering.caf" // default ios sound.
};
query.equalTo("user", {"objectId": "" /* a user object id */, "className": "_User", "__type": "Pointer"}); // me.
query.equalTo("deviceType", "ios");
Parse.Push.send({
where: query,
data: data
}, {
success: function () {
console.log("arguments", arguments);
},
error: function (error) {
console.log("Error: " + error.code + " " + error.message);
}
});
// Install Parse framework for node.js via npm.
// http://blog.parse.com/2012/10/11/the-javascript-sdk-in-node-js/
$ npm install -g parse
// Parse docs about Push Notifications with JavaScript.
// https://parse.com/docs/push_guide#top/JavaScript
@skolesnyk
Copy link

From https://www.npmjs.com/package/parse

For server-side applications or Node.js command line tools, include 'parse/node':

// In a node.js environment
var Parse = require('parse/node');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment