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.




Tuesday 1 September 2015

How to access localhost of my local machine from android

In this post I will explain how to access localhost of your laptop using android.

Those who have worked on making local server and access it from the local machine's browser may know that we can just access the localserver by its ip and port no. on which server is running.

Like Type in browser

http://yourserverip:portno

For example : http://192.168.1.104:80

You can also access the localhost server from phone's browser by typing the same ip and port.

But in Mac OS it does not work sometimes. It gives the error host unreachable.

That is because your router is not able to find the route to the given ip. For this you have to first ping the server ip from your terminal.(if you are using other machine is not android).

open Terminal Type  : ping ipaddreessofserver

Note: Replace ipadressofserver  by your server's ip address.

But If you are in android you might not have a terminal. So Go to play store Download an app called

ConnectBot. 


It basically provides you a terminal to access in android. Type ping ipaddressofyourserver in connectbot app in your android phone. If ping is working then you will be able to access localhost from browser of your android phone.

I hope this is helpful. If you have any other doubts regarding this please comment. If you like the post share it.


Related Posts

Related Posts Plugin for WordPress, Blogger...