Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

skolesnyk commented Nov 26, 2015

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
You can’t perform that action at this time.