Reputation: 1361
I am working on an Android app which uses Google Cloud Messaging (new GCM-API, not deprecated C2DM) for sending send-to-sync messages to all registered devices.
Since I used the official documentation my client implementation works almost exactly the same way like Google´s example. As a server I use a simple PHP script running on localhost whose only task is to send send-to-sync messages to GCM.
Everything works fine as long as my devices are connected to the internet through cellular networks like UMTS (server sends notfication to GCM > GCM pushes notifcation to device as soon as it is online > notification is displayed on device).
But when the device is connected to the WIFI no GCM messages will be received anymore (although Google sends a "success"-reply to my PHP server). Due to the following answer I have already checked if my router blocks some ports but it does not.
I had same problem of receiving push messages, even though GCM server replies "Success", because of wifi privacy. When I used my company wifi, I coudn't receive message in mobile, since they were blocked GCM server port.
Interestingly enough my implementation already has been working with WIFI...
Google´s reply when sending GCM message from PHP:
{
"multicast_id":4677038582377051331,
"success":1,
"failure":0,
"canonical_ids":0,
"results":[{"message_id":"0:1406364179145476%6ce83c64d7d6c7e2"}]
}
The issue solved itself when I called the PHP script which sends my GCM messages from the smartphone and since that everything works fine.
Meanwhile this "new" GCM-API is deprecated either! I am using the latest GCM-API (published in summer 2015) now. Since upgrading I have never faced this issue again. The new API, including InstanceId-API is very recommendable from my point of view, as far as I see it is a more stable than old GCM.
Upvotes: 6
Views: 8487
Reputation: 1361
Meanwhile this "new" GCM-API is deprecated either! I am using the latest GCM-API (published in summer 2015) now. Since upgrading I have never faced this issue again. The new API, including InstanceId-API is very recommendable from my point of view, as far as I see it is a more stable than the previous GCM-API.
Upvotes: 0
Reputation: 3292
If the service worked for you at some time your device "registration id" could be changed or simply wrong.
If never worked for you and after checking that your device registration id is the same that you're sending in the request payload to Google, check your Broadcast Receiver and the GCM intent service that wake up your device, because if this implementation is failing on your app you'll be not receiving any message even if your request is received ok by Google as you're are pointing.
Upvotes: 0
Reputation: 3776
You need to open ports 5228 - 5230 to make GCM work properly.
Check the following:
Note: If your organization has a firewall that restricts the traffic to or from the Internet, you'll need to configure it to allow connectivity with GCM. The ports to open are: 5228, 5229, and 5230. GCM typically only uses 5228, but it sometimes uses 5229 and 5230. GCM doesn't provide specific IPs. It changes IPs frequently. We recommend against using ACLs but if you must use them, take a broad approach such as the method suggested in this support link.
If your Company Wifi does not allow these ports then you will not be able to receive GCM.
Hope it helps
Upvotes: 3