Does anyone have a sample gcm server side and android project? Preferably a tutorial that explains everything.
I have tried to have a look at the one included in the sample however I haven't been able to get it work.
I have a c2dm project which works both server side and android, but I don't know how to convert this to gcm.
I will be using gcm to push messages
any help would be appreciated
PRO TIP: Google Cloud Messaging for Android (GCM) is a service that allows developers to send data from their servers to their users' devices, and vice versa. GCM is completely free, and you can use it to send or receive any data, up to 4kb in size. You can then add recipients, recipients' addresses, and messages.
Firebase Cloud Messaging (FCM) provides a reliable and battery-efficient connection between your server and devices that allows you to deliver and receive messages and notifications on iOS, Android, and the web at no cost.
FCM is the new version of GCM under the Firebase brand. It inherits GCM's core infrastructure to make sure we continue to deliver messages reliably on Android, iOS and Chrome. Save this answer.
The collapse key parameter identifies a group of messages (for example, with collapse_key: updates available) that can be collapsed, so that only the last message is sent when delivery resumes. The feature helps you avoid sending the same messages when the device becomes active.
just follow this tutorial
hope it will help you.
GCM SERVER-SIDE (java code)
public class GCMServerJava {
/**
* @param args
*/
public static void main(String[] args) {
Sender sender = new Sender(enter your App id);// app id
Message message = new Message.Builder()
.collapseKey("1")
.timeToLive(3)
.delayWhileIdle(true)
.addData("message",
"this text will be seen in notification bar!!").build();
Result result;
try {
result = sender.send(message,"registration id which client get after registering device with google gcm service", 1);
System.out.println(result.toString());
Message message1 = new Message.Builder()
.build();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With