Sunday 13 September 2015

How to send notification using parse by Java Script on Node.js

In this post I am going to describe how to send notification using parse in java script on Node.js server. ( This post is for mac and linux guys, but by changing corresponding commands it will also work with windows)

1. If you are using node.js, you must know about npm (node package manager), Install npm first.

sudo install npm

type the password of your pc and it will install npm.

2. After installing npm, Install parse using Terminal Command

npm install parse

3. Include the parse module in your file and initialise it with the required keys.

var Parse = require('parse/node').Parse;
Parse.initialize( PARSE_APP_ID,  PARSE_API_KEY , PARSE_JAVA_SCRIPT_KEY);

All above keys you can find on your parse Dash Board. Visit

www.parse.com

Go to the app in which you want to add this functionality and click on keys. There you can find all the Keys.

4. Now all things are set for sending Notification write this function

 var query = new Parse.Query(Parse.Installation);
 query.equalTo('deviceType', 'android');  

// you can set all other conditions if you want, channel type, deviceId, installationId etc...

 Parse.Push.send({
     where: query, // For personalise the notification
     data: {
        alert: "Hi, Best of Luck !!" 
      }
     }, {
         success: function() {
               // Push was successful
               console.log('successful');
         },
         error: function(error) {
                 // Handle error
                 console.log('error');
        }
 });


Now you are ready to send notification on any app which has parse sdk integration. I will describe parse sdk integration in next posts.

I hope it helps. If you have any other queries, you can ask in comment or drop me a mail.
Thanks for reading this post.




No comments:

Post a Comment

Related Posts

Related Posts Plugin for WordPress, Blogger...