Handle Multiple Responses of same type Google Cloud Messaging Server

I have implemented Google Cloud Messaging for a user profile.

When the user updates the profile on the web app, it instantly sends a GCM request to GCM Server, and from there it is sent to my registered Android Device and the user profile is updated on the device.

But when the device is Offline, and the user updates the user profile two times. Two requests are sent when the device comes online, how to get only the recent request ?

Any help would be appreciated. Thank you in advance.

-------------Problems Reply------------

That's what the collapse_key parameter is for. If you send two GCM messages with the same collapse_key to the same device, if the device is offline, the GCM server stores only the last message and will deliver a single message to the device when it gets back online.

Here's a quote about collapse_key :

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). However, if the collapse key is not set, both the new and old messages are stored for future delivery. Collapsible messages are also called send-to-sync messages.


The syntax is simple. For example, if you are sending a JSON request, add the following :

"collapse_key" : "something",

The collapse key doesn't have to be unique for each device.

Category:android Views:3 Time:2018-03-06

Related post

  • How servlet handle multiple request from same jsp page 2012-01-05

    Sorry friends if this question is very easy but i am confuse i unable to find out solution. As we all know in spring MVC framework we create controller which will handle multiple request from same page using @requestmapping annotation. but same thing

  • Google Cloud Messaging in Delphi XE5? 2013-09-16

    I've got an android app that I am thinking about porting to Delphi but I can't see a way to interface with GCM. I am thinking I would possibly have to run the GCMBaseIntentService in java and interface with the delphi shared object? Alternatively, I

  • Can not enable "Google Cloud Messaging for Android" at Google Cloud Console 2014-01-07

    I am following the instruction from GCM get started and I already created a API project, however when I went to enable the Google Cloud Messaging for Android, I would get the popup like this: , however after I checked the checkbox and click accept, t

  • Android phonegap send push notification using Google Cloud Messaging using php 2014-05-15

    I have developed the android application in cordova 3.4 now I want to get the automatic notification to their mobile. For this I refer websites as below http://devgirl.org/2013/07/17/tutorial-implement-push-notifications-in-your-phonegap-application/

  • Maximum stored non-collapsible messages on Google Cloud Messaging Servers 2015-01-14

    In the Google Cloud Messaging documentation about Messages with Payload I found the following information: GCM will store up to 100 non-collapsible messages. After that, all messages are discarded from GCM, and a new message is created that tells the

  • Retrieve Heroku App IP Address for Google Cloud Messaging 2015-10-06

    I am attempting to integrate Google Cloud Messaging with my Heroku Apache PHP Server so as to allow for push notification to sync app data with the server as new data arises. However, the present step in GCM requires the servers (Heroku App's) IP add

  • Handle multiple versions in same URL 2011-08-10

    what I'm trying to do is to handle multiple versions of the same web application, somewhat like Google does with some of their products where you get the "Try the new version" link. The goal is to have both a "stable" and a "beta" version of the weba

  • try- catch. Handling multiple exceptions the same way (or with a fall through) 2010-02-18

    There has already been a question posted here which is very similar. Mine is extending that question a bit more. Say you want to catch multiple types of exception but want to handle it the same way, is there a way to do something like switch case ? s

  • C++ fixed size arrays vs multiple objects of same type 2011-01-30

    I was wondering whether (apart from the obvious syntax differences) there would be any efficiency difference between having a class containing multiple instances of an object (of the same type) or a fixed size array of objects of that type. In code:

  • AppEngine - Multiple Relations of Same Type 2011-06-11

    I need to have two objects of the same type. By default appengine doesn't allow it, but I found this parameter: datanucleus.appengine.allowMultipleRelationsOfSameType, so I can save the two same type objects. In debug mode, before calling the makePer

  • jersey jackson multiple providers for same type 2012-03-17

    With Jersey, I am currently using the Gson library to convert my pojo to json back and forth. However, I've discovered Jackson to be a lot faster so we are switching to this. I already have a Gson custom Provider and Reader, and will now create (a mo

  • How to handle multiple responses from single web service call in Flex? 2010-05-20

    I have a requirement where a web service call should be fired from the flex side and this web service is an async web service which would return more than one response. In current Flex environment that I have worked in , when we call a webservice - w

  • how to handle the response from the payment gateway, if our server goes down 2012-02-02

    For example in paypal when completed the payment, the response is going to response.php at that time if our server goes down. how to handle this situation and what need to be done. In other payment gateway also how to handle the situation when our se

  • QT NOOB: Add action handler for multiple objects of same type 2010-05-10

    I have a simple QT application with 10 radio buttons with names radio_1 through radio_10. It is a ui called Selector, and is part of a class called TimeSelector In my header file for this design, i have this: //! [1] class TimeSelector : public QWidg

  • Message Queueing - Handling multiple responses simultaneously - C#.NET 2010-02-19

    I've a business application where i've a master application and multiple slave applications (geographically distributed) connected to each other. All the slave application interact through master application and master application should handle all t

  • Database design: Multiple of the same type of item 2011-02-24

    I wasn't sure entirely how to word this for the question, so I'll explain what I'm thinking. I have previous experience designing databases but really haven't decided how I want to implement this or run across this before. I'll explain what I'm think

  • handle multiple controls with same name in form collection 2011-04-29

    I have a form in my asp.net mvc(C#) application which handles some dynamic controls. On a button click "Add Row", i will add a row dynamically to the existing table as: $('#btnAddMore').click(function() { var _userBodyHtml = ''; _userBodyHtml += '

  • In Java, How do I represent multiple objects (of same type) in a single JSON object 2011-06-20

    I need to pass the attribtutes of particular type, as apart of a restful service to a javascript which will then display them to a webpage @GET @Produces("application/json") @Consumes("application/json") @Path("/getStatusAll") public void getStatusAl

  • Sharepoint StateMachine : Handling multiple responses to multiple created tasks 2008-10-16

    I created a StateMachine workflow for sharepoint and at one state, I create multiple tasks using a replicator. The number of tasks created is variable. I need to handle the OnTaskChanged event for all the tasks I created which seems impossible as one

  • Selenium: handling multiple inputs with same xpath 2011-11-25

    I am testing a website where the user has an option to change the input fields to Textbox and Dropdown. Whether the user changes it to dropdown or textbox, the xpath for the input field is the same. So, I am not sure how to write the test steps for t

  • Handling multiple routes with waypoints in Google Maps v3 2012-04-13

    I want to display multiple directions with dragable waypoints and save each waypoints associating with origin, destination in object or database whenever Route.prototype.setWayPoints() is called. This guy is doing that with single route with dragable

  • PHP Imbot Issues ( how to handle multiple responses for imified.com). how to send response in PHP and still call other functions 2010-08-31

    I was developing a IMbot using imified.com This is how it works: the bot will call a URL with post method passing the Text in a input field. So we can output the data to that request and it will sent to the USER Chat window. But my script is taking t

  • Python: define multiple variables of same type? 2010-12-10

    Probably a duplicate, but I can't find the answer by searching with these terms, at least. Is there a quicker way to do this in Python? level1 = {} level2 = {} level3 = {} I've tried level1 = level2 = level3 = {} But that seems to create copies of th

  • Use "references" for multiple items of same type 2008-12-10

    So I'm teaching myself Ruby on Rails, with a PHP background. I've written a sloppy, proof-of-concept PHP application called "2NDP." I want to re-create this in Ruby on Rails (but more basic, more clean, and with a better interface), so I can learn so

  • Multiple attributes of same type fail when using Ninject's BindFilter 2012-03-08

    As part of a identity-enabled authorization system, I'd like to use IAuhtorizationFilter and Attributes to restrict access to action methods in my controllers. I've got things working very well, partly due to help from the following resources: Ninjec

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.125 (s). 11 q(s)