I have an android app that relies on GCM push notifications, and sometimes, a user's device will stop receiving push notifications. The behavior is quite intermittent: on some devices, it will never fail and just keep working for weeks or months, while on other devices, it will work for a few days, and then just randomly stop receiving pushes.
Every time the device has stopped working, I've verified that the device has a valid regId from GCM, and that my server is sending pushes to that regId. However, the logs show that the device is not receiving anything. Here is what the logs on a normal push receive looks like:
05-15 10:39:21.091: V/GCMBroadcastReceiver(13766): onReceive: com.google.android.c2dm.intent.RECEIVE
05-15 10:39:21.091: V/GCMBroadcastReceiver(13766): GCM IntentService class: com.medigram.v2.GCMIntentService
05-15 10:39:21.091: V/GCMBaseIntentService(13766): Acquiring wakelock
05-15 10:39:21.111: V/GCMBaseIntentService(13766): Intent service name: GCMIntentService-468134393228-13
05-15 10:39:21.131: V/GCMBaseIntentService(13766): Releasing wakelock
05-15 10:39:21.171: V/GCMBroadcastReceiver(13766): onReceive: com.google.android.c2dm.intent.RECEIVE
05-15 10:39:21.171: V/GCMBroadcastReceiver(13766): GCM IntentService class: com.medigram.v2.GCMIntentService
05-15 10:39:21.171: V/GCMBaseIntentService(13766): Acquiring wakelock
05-15 10:39:21.241: V/GCMBaseIntentService(13766): Intent service name: GCMIntentService-468134393228-14
05-15 10:39:21.271: V/GCMBaseIntentService(13766): Releasing wakelock
None of this shows up on the devices that have stopped receiving pushes, and as a result, neither is the onMessage() method of my GCMIntentService called.
The strange thing is, when I switch the device connection from 3G/4G to wifi or vice versa, it starts working again, and the device gets all the backlogged pushes at once. What exactly happens when the connection type changes?
In case it helps, here are some things I've tried on devices where push is working to manually reproduce the problem, but to no avail:
-I first thought it could be a context issue, but that was quickly ruled out when simply switching networks resolved the issue. I tried investigating further anyway by using the 'Dont keep activities' developer option and then backgrounding the app, but this had no effect on push.
-I've tried force stopping the app to see if it would cause push to stop working, but the issue doesn't seem to have anything to do with the app being force stopped, as it keeps working.
-I've tried putting the phone on airplane mode and coming back, but push kept working.
I would greatly appreciate it if somebody could point me in the right direction, as I've pretty much exhausted all of the resources on stackoverflow and the google. I'm still just as clueless about this issue as when I started.