When device is connected internet, I can't get old messages- GCM

前端 未结 1 1955
情书的邮戳
情书的邮戳 2021-01-29 01:19

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

相关标签:
1条回答
  • 2021-01-29 01:52

    you can get all the messages send to your device.

    GCM server keeps account of your all messages send to your device. And it shows these in notification area whenever device get connected to Internet.

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

    your code probably using this :

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

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

    Such As :

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

    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 !!

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