3

hi I cannot see any explanation of the implementation of the collapse_key. I think i understand what it does but not how it do it! Android Cloud to Device Messaging Framework

I have a C2DM framework set up and sending 4 types of messages to many phones.

String messages very basic looks kind of like this:

type:name:uuid
type:name:uuid:number
type:uuid:id

If the phone is off many of this can get piled up waiting for phone on-line. as far as i can tell my system works but what will the collapse_key do for me here?

addEncodedParameter(sb, "collapse_key", "no_ide_what_to_put_here");

Erik
  • 5,039
  • 10
  • 63
  • 119
  • I found this text: “collapse key” used for overriding old messages with the same key on the Google C2DM servers" I think if im retrying sending same message 3 times I must use same key value right. Google cloud server will send the latest msg with the same key value – Erik Apr 12 '11 at 19:05
  • 1
    Yep, and if you want each separate message to be delivered then each collapse-key should be different/unique. – Kasium Apr 12 '11 at 19:43

3 Answers3

5

You mentioned retrying the same message 3 times and using the same key value. It doesn't really have to be the same message. If you've got a message that indicates the current price of a stock, for instance, and you really only care about the latest price, then you could send different messages with the same key. When the device comes back online, it only gets the latest price quote message.

This may have been what you were saying already, but wanted to make it clear it's not only for "retrying sending same message".

Ryan Hope
  • 66
  • 1
  • Actually, Google says that: "Note that since there is no guarantee of the order in which messages get sent, the "last" message may not actually be the last message sent by the application server." See: http://code.google.com/android/c2dm/#push – Ted Feb 28 '12 at 02:32
2

I found this text: “collapse key” used for overriding old messages with the same key on the Google C2DM servers" I think if im retrying sending same message 3 times I must use same key value right. Google cloud server will send the latest msg with the same key value

Erik
  • 5,039
  • 10
  • 63
  • 119
1

...but be aware of the following (from http://code.google.com/intl/sv-SE/android/c2dm/):

"Note that since there is no guarantee of the order in which messages get sent, the "last" message may not actually be the last message sent by the application server."

But maybe this is not an issue if you don't generate a lot of messages.

Oak
  • 26
  • 1