当设备连接互联网,我不能让老messages- GCM [英] When device is connected internet, I can't get old messages- GCM

查看:113
本文介绍了当设备连接互联网,我不能让老messages- GCM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然我的设备没有互联网连接,我送邮件从服务器到应用程序GCM。此后,当设备连接互联网,我不能得到的消息。它是正常的吗?

While my device has not internet connection, I am sending message from server to application with GCM. After that, when device connect the internet, i can't get the message. Is it normal?

http://developer.android.com/guide/google/gcm /adv.html

如果设备没有连接到GCM,该消息将被存储,直到建立了连接(再次尊重崩溃键的规则)。

我的邮件具有相同崩溃的关键;但我仍然有连接设备时得到的只有1的消息。

My messages have same collapse key; but still I have to get only 1 message when device is connected.

推荐答案

您可以得到所有的信息发送到您的设备。

you can get all the messages send to your device.

GCM服务器保留的所有邮件的帐户发送到您的设备。它在每当设备可以连接到互联网的通知区域显示这些。

您也越来越只有一个消息,因为要分配相同的通知ID 通知()您code函数

You are getting only one message because you are assigning same NOTIFICATION ID in notify() function of your code

可能使用此您code:

your code probably using this :

        // 0 is notification id
        notificationManager.notify(0, notification); 

更改您的通知ID 每次获得在通知区域中的所有消息。

change your NOTIFICATION ID everytime to get all messages in notification area.

如:

        static int NOTIFICATION_ID = 0;

        if (NOTIFICATION_ID > 1073741824) {
            NOTIFICATION_ID = 0;
        }
        notificationManager.notify(NOTIFICATION_ID++, notification);

如果子句让你从int值溢出安全。您可以根据您的要求忽略它。

if clause keeps you safe from overflow of int value. You can ignore it according to your requirement.

我已经测试了这种情况。现在轮到你了。
乐于帮助!

I have already tested this scenario. Now its your turn.
Happy to Help !!

这篇关于当设备连接互联网,我不能让老messages- GCM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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