GCM在怠速后,没有收到 [英] GCM not received at after idle

查看:144
本文介绍了GCM在怠速后,没有收到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序接收GCM的消息立即如果手机连接到网络。但是,当用户关闭网络和经过长时间的间隙(约2小时)重新连接的设备没有接收到消息。

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 reconnects after a long gap (around 2 hrs).

我还没有添加TTL,因此假定这将是4周。

I have not added TTL, so assuming it would be 4 weeks.

示例消息:

{
    "registration_ids":["APA9xxx........."],  
    "delay_while_idle":false,  
    "collapse_key":"New Message",  
    "restricted_package_name":"com.sample.gcm",  
    "data":{  
        "app":2,  
        "product":"message",  
        "notif":"03lm9h"
    }
}

我缺少的东西确实让当交货被延迟它的工作?

Am I missing something do make it work when delivery is delayed?

请,我指向的链接,可以帮助我解决这个问题。

Kindly, point me to links which can help me in solving this problem.

在此先感谢。

推荐答案

您delay_while_idle应该是真实的,从 GCM APi的文档

You delay_while_idle should be true, from GCM APi docs

如果所连接的设备,但空闲,该消息将仍然被递送马上除非delay_while_idle标志设置为真。否则,它将被存储在服务器GCM直到设备是清醒的。而这也正是collapse_key标志起到了重要作用:如果已经与存储,等待交付,旧的信息将被丢弃,新的消息将取代其位置相同的崩溃键(和登记ID)的消息(也就是,旧的消息将被新的被折叠)。

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).

您使用的是可折叠键,只有一个会保持GCM服务器上,而设备处于空闲状态。

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

在code:

Message message = new Message.Builder()
    .delayWhileIdle(true)
    //..

这篇关于GCM在怠速后,没有收到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆