Receive Android GCM messages so slow?

徘徊边缘 提交于 2019-12-02 07:17:37

GCM uses throttling when there's excessive use, see the following document for more details:

http://developer.android.com/google/gcm/adv.html#throttling

andQlimax

Please read my answer here:

Google Cloud Messaging - messages either received instantly or with long delay

It's basically a tcp timeout problem

You can manually trigger the heartbeat to keep the connection alive by the following code. Some network routers will automatically kill the idle socket connections if it is idle for a particular time period (sometimes 5 minutes). Execute the code in every 5 minute so that the connection will be re-established if it is closed. But, obviously reducing the interval will consume bit more battery (I don't know how much it is relevant here because nowadays the smart phones come up with high mAh battery).

getApplicationContext().sendBroadcast(new Intent("com.google.android.intent.action.GTALK_HEARTBEAT"));
getApplicationContext().sendBroadcast(new Intent("com.google.android.intent.action.MCS_HEARTBEAT"));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!