Rainer Lang Rainer Lang - 1 year ago 90
Android Question

GCM Push Notifications are not delivered to devices

We (Panos and Rainer - see the comments down) have a server and several Android devices.

We want to send push notifications from our server via GCM to the Android devices.

Now we make a post request to the GCM server. The GCM server response is that all is fine (success==1 and even the message-id)!
BUT the push notification(s) are never delivered to the devices.

If we use the same data and the Chrome addon Postman - the notifications are delivered immediately.

We tried all lot of different solutions. We get always the feedback of the GCM server that all is ok - but the push notifications aren't send.

We also tried this one:

Answer Source

You might also post the URL you use. There is a new GCM enpoint which looks like the following:


I am not yet sure what's causing the issues on your side. But the following is tested and working:

public class Main {

    public static void main(String[] args) {
    // write your code here

        try {

            String url = "https://gcm-http.googleapis.com/gcm/send";

            URL obj = new URL(url);
            HttpsURLConnectionImpl conn = (HttpsURLConnectionImpl) obj.openConnection();

            conn.setRequestProperty("Content-Type", "application/json");

            conn.setRequestProperty ("Authorization", "key=***");

            String title = "Short title";
            String body = "A body :D";
            String token = "****";
            String data =  "{ \"notification\": { \"title\": \"" + title +"\", \"body\": \"" + body + "\" }, \"to\" : \"" + token + "\", \"priority\" : \"high\" }";
            OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream());

            String text = getText(new InputStreamReader(conn.getInputStream()));
        } catch (Exception e) {

    public static String getText(InputStreamReader in) throws IOException {
        StringBuilder sb=new StringBuilder();
        BufferedReader br = new BufferedReader(in);
        String read;
        while((read=br.readLine()) != null) {
        return sb.toString();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download