Java – Use Java gcm-server to send messages to topics

Use Java gcm-server to send messages to topics… here is a solution to the problem.

Use Java gcm-server to send messages to topics

I’m using Java gcm-server to send messages to Android client applications, and I want to send messages to a specific topic, as shown in the image here .

My problem is that I can only send messages to registration_ids list using the Sender class, and I don’t know how to use the parameter “to”: “/topics/myTopic” (I read the source code and it doesn’t seem to be implemented).

Any suggestions?

Solution

Yes, now… Not implemented yet,

You need to make an HTTP POST request to the following address:

https://android.googleapis.com/gcm/send

body

{
“Data”:
{
“title”: “test title”,
“message”: “Your message”
},

to”: “/topics/global”

More Help –
https://github.com/googlesamples/google-services/blob/master/android/gcm/gcmsender/src/main/java/gcm/play/android/samples/com/gcmsender/GcmSender.java

Related Problems and Solutions