GCM not received at after idle

前端 未结 1 349
忘掉有多难
忘掉有多难 2020-12-22 02:06

My app receives the GCM messages instantly if the phone is connected to the network. But the devices does not receive the messages when user turns off the network and reconn

相关标签:
1条回答
  • 2020-12-22 02:46

    You delay_while_idle should be true, from GCM APi docs

    If the device is connected but idle, the message will still be delivered right away unless the delay_while_idle flag is set to true. Otherwise, it will be stored in the GCM servers until the device is awake. And that's where the collapse_key flag plays a role: if there is already a message with the same collapse key (and registration ID) stored and waiting for delivery, the old message will be discarded and the new message will take its place (that is, the old message will be collapsed by the new one).

    You are using a collapsable key so only one will be keep on the GCM servers while the device is idle.

    In the code:

    Message message = new Message.Builder()
        .delayWhileIdle(true)
        //..
    
    0 讨论(0)
提交回复
热议问题