Last active
January 8, 2019 05:10
-
-
Save nebiros/9196645 to your computer and use it in GitHub Desktop.
Send Push Notifications from node.js with Parse.com SDK
This file contains hidden or 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
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); | |
} | |
}); |
This file contains hidden or 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
// 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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');