Receive Android GCM messages so slow?

后端 未结 3 631
我寻月下人不归
我寻月下人不归 2021-01-25 11:29

Google Cloud Messaging (Push message) problem.
I have two smartphones(HTC Sensation XE, Desire HD) and a tablet(Samsung Galaxy Note 10.1 Wifi).
Sometimes I need to w

相关标签:
3条回答
  • 2021-01-25 12:08

    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"));
    
    0 讨论(0)
  • 2021-01-25 12:23

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

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

    0 讨论(0)
  • 2021-01-25 12:27

    Please read my answer here:

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

    It's basically a tcp timeout problem

    0 讨论(0)
提交回复
热议问题