Skip to content

Instantly share code, notes, and snippets.

@leonardocordeiro
Created January 25, 2015 20:04
Show Gist options
  • Save leonardocordeiro/808119c7b1dbe1f95187 to your computer and use it in GitHub Desktop.
Save leonardocordeiro/808119c7b1dbe1f95187 to your computer and use it in GitHub Desktop.
GCM Server-side
package br.com.caelum.gcm;
import java.io.IOException;
import com.google.android.gcm.server.Message;
import com.google.android.gcm.server.Sender;
public class EnviarMensagem {
private static final String API_KEY = "";
private static final String DEVICE_ID = "";
public static void main(String[] args) throws IOException {
System.out.println("Enviando mensagem...");
Message message = new Message.Builder()
.addData("message", "Olá")
.build();
Sender sender = new Sender(API_KEY);
sender.send(message, DEVICE_ID, 5);
System.out.println("Enviada!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment