android - 有时在移动设备中不接收推送通知 GCM

标签 android push-notification google-cloud-messaging

我遇到了一个奇怪的问题。如果从服务器端发送消息时它已连接到互联网,我会在我的手机中收到推送通知。但是如果当时它没有连接到互联网,而是我在一段时间后连接到互联网。我没有收到该通知。据我所知,只要我们在线,所有这些通知都应该显示,因为 GCM 服务器存储了所有这些消息。我收到所有其他应用程序的通知。此外,我已在 list 中授予唤醒锁权限。可能是什么问题?服务器端、客户端或移动端的任何内容?请帮助...

此值从第 3 方服务器(.Net 服务器)发送到 GCM 服务器:

String postdata= "collapse_key=score_update&time_to_live=2419200&delay_while_idle=1&data.message=‌​" + 
message + "&data.time=" + System.DateTime.Now.ToString() + "&registration_id=" + deviceToken + ""

提前致谢

最佳答案

delay_while_idle=1另外我在 list 中赋予了唤醒锁权限

delay_while_idle=1 表示如果设备处于空闲状态(关闭、离线、锁定屏幕等...),消息将不会到达设备。如果您希望唤醒锁权限有所不同,请将其更改为 0。

只是为了澄清 - 消息应该在设备停止空闲后到达设备(只要它没有空闲太久,其中“太长”由指定的 time_to_live 确定).

这是 GCM 文档中的相关引述:

delay_while_idle

If included, indicates that the message should not be sent immediately if the device is idle. The server will wait for the device to become active, and then only the last message for each collapse_key value will be sent. Optional. The default value is false, and must be a JSON boolean.

time_to_live

How long (in seconds) the message should be kept on GCM storage if the device is offline. Optional (default time-to-live is 4 weeks, and must be set as a JSON number).

关于android - 有时在移动设备中不接收推送通知 GCM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14746092/

相关文章:

java - 删除recycleView中的sqlite条目

java - 有没有办法在Azure MobileServiceSyncTable中进行计数查询?

java - Android模拟器访问IIS Express

ios - 单击用户通知时直接进入特定 View

ios - Apple Push Notifications - 将数据放入应用程序

android - 在自动更新期间保持应用程序 GCM 注册 ID 有效

android - Grails android-gcm 插件安装

java - 无法与 TTS 同步在 recyclerVIew 中显示 imageView

ios - 就推送通知而言,Firebase + Batch 是 Parse 的良好替代品吗?

android - 在 iOS 和 Android 上处理推送通知场景