Communicate between Android phones using GoogleCloudMessaging - android

I'm new in android development. I'm trying to develop an app in which a user can send a request to another device running the same app and it should return a response/notification to the sending device.
I googled it and found that GoogleCloudMessaging can be used for that. But all the tutorials say that it can be used to send messages from server to apps. I need to know how the reverse can be done, ie send messages from app to server..
Please provide some tutorial.
Any help is appreciated.
Thanks..

If you want to send data to your server, you can use rest communication.
Here a tutorial

Step 1: Call a server side script*(REST api/ Webserices)* from your android application using HttpPost/HttpGet,
Step 2: Wait for response coming from server and use it.
Note: don't forget send all needful data for your request from your app to server by httppost.
Go through these link this will help you.
Get started with push notifications in Mobile Services.
Android Push Notifications using Google Cloud Messaging (GCM), PHP and MySQL
.
Google android doc on GCM,
Google Cloud Messaging GCM for Android and Push Notifications

Related

How to build a server for GCM

I know how to implement GCM in my App but I don't know how to build a server able to send notification to ALL the users.
I need something quite simple (just sending notification), could you advise me any services and tutorial in order to set up the server?
I wish something not to complex, because everything that I will need from my app is receiving whether simply notifications to display or to tell the app that some new data is available for downloading.
Thank you!!
Prerequisite for GCM Application
Google API Server Key
GCM RegId of the Android Device to communicate via GCM
If you get clear concept about GCM, please visit here
If you want to use java for server side then visit my answer.
Related Links:
Android Push Notifications using Google Cloud Messaging (GCM), PHP and MySQL
Android Warriors
If you're using PHP, you could use this approach to send GCM message to your client refer this
You could setup your own local server on PHP using AMPP. refer this
Probably, the simplest way is to add a cloud endpoint module refer this. Then, write a simple service refer this that sends the messages. Finally, let Android Studio deploy it.

How server can ping Android application

In my Android application there is a requirement to ping Android application from Server, is it really possible? Or only possible way is to ping Server from Android app.
Please share your ideas on how server can ping Android application. Also share code snippets if you have
Thanks
Use Google Cloud Messaging for Android: Google Cloud Messaging
Here is a good post for beginners. Find Here
You can implement GCM Client and Server to ping your application instead of showing a notification. GCM allow to send data upto 4kb of payload.
Please go through How to implement GCM server and GCM Client on the link.

The difference between GCM and PARSE push messages

I am buiding an android app which will be receiving notifications from my server. This means all my users which is above 1 million, will receive notifications from my server. I know parse and google cloud messaging(GCM) can do the push messages but please I want to know the best out of this two (parse and GCM) so I can implement it. Thanks in advance.
If you look at https://parse.com/tutorials/android-push-notifications you can see:
The Parse library provides push notifications by using Google Cloud Messaging (GCM).
So you have to register your app to GCM console to send push notification in anyway.
When to NOT use parse.com?
If you already have a backend service, you can easily implement push notification since there are plenty of third part libraries for different platforms such as node.js, php etc.
When to use parse.com?
If you don't have backend-service and you just want to send push notifications also if you don't want to spend your time by setting up server stuff then you can go with parse.com
NOTE: Facebook shuts down parse by January 2017 so please consider it.(http://blog.parse.com/announcements/moving-on/)
Android push notification is a service used to send messages directly to the Android Mobile Devices.
There are several ways we can implement Android push notification.
Google Cloud Messaging(GCM)
Parse Notification(Parse.com)
You are asking which one is the best way to implement :
The standard way is using GCM (Google Cloud Messaging) but there are some alternatives like Parse Notification,Which is easier to use.
If you need to handle Json Push messages,Refer this link
Steps involved in send Push notifications:
Developing the application involves two parts:
GCM Server Application – Create Web application using Php to send message to User via GCM Cloud server
GCM Client Application – Create Android application which receive message sent from GCM Server Web App
For More Informations regarding to GCM server and Client Application
Parse uses GCM and uses own service for Kindle
Please Go with google cloud messaging(GCM) .It is very easy to integrate in android app. the problem with parse in some case device token or registration id is not register at their database so User of parse does not get push notification.In case of GCM we can sure for device token
So my recommendation is GCM
Hope this will help you.

Android Notification through PHP MySql

I want to implement notification of news or article in Android.User can put the new article or news on the server after that i want to show notification in my app through PHP MySql.Can someone help me how to do this.Thanks to appreciate.
PHP is a server side process - it only runs when a user/app/service requests the page.
MySQL is a server based database. It's not "connected" to your app.
Your app must then "poll" your website (it has to request data from it periodically). This is best done using an XMPP type service. You can find a lot of info on XMPP - basically, it's complicated to setup and run. It probably isn't worth doing unless you've already done it.
Alternatively, you can use an existing XMPP service. Google Cloud Messaging (GCM) is an excellent option for most Android devices (any that has Google Play installed... so, it won't work on an Amazon Fire phone, for example). It's not "easy" to setup, but they do a lot of really hard stuff for you. Also, there are a lot of references for setting it up, like this from Google:
https://developer.android.com/google/gcm/client.html
You can use Google cloud messaging to display Notification or You need to create a service that always ping your server for new message.
please try 1st options its better.(2nd options is worst because it use more battery & internet data )
You can use google cloude messaging service to send notificaion in device so please register your application on google service all step are cover below link.
Open below link and follow step
http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
You can use GCM (Push notification) and implement the notification generated method inside onMessage method.
For reference use this linkAndroid Push Notifications using Google Cloud Messaging (GCM), PHP and MySQL
What you are looking is Google cloud messaging.
For Gcm you have to write a server in your case is php server.
For Gcm server code or for testing purpose refer this link.
Android: Test Push Notification online (Google Cloud Messaging)
But firstly it is best to learn about GCM itself and it's mechanism.
For this you can refer this link.
https://developer.android.com/google/gcm/index.html
You have to do some settings in Google console which are all explained in this article including the android side code.
Hop i helped you.

implementing GCM communication

I want to implement GCM communication in order to create push notifications, from my application server to all the devices that my app is installed via GOOGLE's servers.
I have found a library that helps me do this the Parse library and using the dashboard given I've sent a push notification from server to device and vice-versa.
The thing is that I want to be able to use the push notification (server side) from my website and not having to log in in Parse's. I'm pretty clueless about this, So I'd appreciate any direction and suggestion given
You may start with these tutorial
Using asp.net
Redth/PushSharp - A server-side library for sending Push Notifications to iOS (iPhone/iPad APNS), Android (C2DM and GCM - Google Cloud Message), Windows Phone, Windows 8, Amazon, Blackberry, and (soon) FirefoxOS devices!
Push Messages to GCM server using visual c#.net application (server side).
And using PHP and MySQL
Android Push Notifications using Google Cloud Messaging (GCM), PHP and MySQL
And using Parse API
if you want to send pushnotification from parse API (not dashboard) then see
Push Notification Guide
There are docs in Parse for sending push notification from Ios,Android,.net,Javascript,php and REST services, use one them which is appropriate for you.
https://parse.com/docs/push_guide#top/JavaScript

Categories

Resources