Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCM java server example

Does anyone have a link to GCM java 3rd Party Server example? I can't understand how to implement it. In http://developer.android.com/google/gcm/server.html, I could not find a complete example.

like image 687
ViT-Vetal- Avatar asked Mar 07 '14 21:03

ViT-Vetal-


People also ask

What is GCM server?

Google Cloud Messaging (GCM) is a service that allows you to send push notifications from your server to your users' Android devices, and also to receive messages from devices on the same connection.

What is GCM in github?

Google Cloud Messaging (GCM) is a service that lets developers send data from servers to users' devices, and receive messages from devices on the same connection.


1 Answers

The easiest way is to use gcm-server.jar (which you can get from here).

Then the code you'll need to send a GCM message will look like this :

Sender sender = new Sender(apiKey);
Message message = new Message.Builder()
    .addData("message", "this is the message")
    .addData("other-parameter", "some value")
    .build();
Result result = sender.send(message, registrationId, numOfRetries);
like image 163
Eran Avatar answered Oct 12 '22 20:10

Eran