GCM - Max length for Registration ID

31,895

Solution 1

I am interested in know about this also. My reg id size is 183 chars. I suspect it won't be longer than 512 chars though, let alone 4K. Imagine sending bulk notification, a 4K reg id x 1000 = 4MB message size!

In the end, I just use the 'text' type in my MySQL table to store the registration id. So even if google send me a 1K, 2K, or 4K (very unlikely) reg id, I will be able to handle it.

Update: I have come across a new reg id size: 205.

Solution 2

On android-gcm forum a google's developer confirms it's 4k

Share:
31,895

Related videos on Youtube

Raj Chaudhari
Author by

Raj Chaudhari

Updated on August 10, 2020

Comments

  • Raj Chaudhari
    Raj Chaudhari over 3 years

    Update: GCM is deprecated, use FCM

    What is the maximum length for a Registration ID issued by GCM servers? GCM documentation do not provide this info. Googling for this reveals that Registration ID is not fixed length in nature and can be up to 4K (4096 bytes) in length. But these are not official answers from Google. I am currently receiving Registration IDs which are 162 characters long. Can anybody help?

  • Jakob Alexander Eichler
    Jakob Alexander Eichler over 11 years
    so the max gcmId length is 512 characters?
  • azgolfer
    azgolfer over 11 years
    That's the thing, we don't know how long it could be. So far the longest I have seen is 205 characters. Perhaps others can chime in if they've seen a longer one.
  • Jake
    Jake almost 11 years
    This refers to the notification payload, not the registration id.
  • Andrew Westberg - BCSH
    Andrew Westberg - BCSH about 10 years
    Your package name for your app has an effect on the size. In my testing, we've seen that by reducing the package length, it reduces the size of the registration token sent from GCM.
  • sports
    sports about 10 years
    Using "text" type in your MySql table won't let you create an index for it.
  • Stan
    Stan about 10 years
    what about storing the MD5(reg_id)? 32 chars, unique. in addition of indexing this is the good solution as for me, at least it looks like. Of course you could also store the original key however use Hashed key for all the operations.
  • L. G.
    L. G. almost 10 years
    Another thread, same answer from a Google developer: groups.google.com/forum/#!topic/android-c2dm/AUGlvmJPyMM Just as confirmation...
  • Pijusn
    Pijusn over 9 years
    @stan Out of curiosity, what is GCM registration ID good for apart sending messages? More specifically, what is its hash good for?
  • Stan
    Stan over 9 years
    @Pius For indexing on server's DB like MySQL?
  • Pijusn
    Pijusn over 9 years
    @Stan I think using Android ID is better because it has a fixed length + can be used for identifying devices which is almost always what you need to search by.
  • Stan
    Stan over 9 years
    omg. Can't you understand - its about storing tons of user's GCM IDs on server and indexing them?
  • mwm
    mwm about 9 years
    they can confirm whatever they want! the only thing a developer needs is a decent documentation on this value... is that so hard? that's how you get bugs in an application when you are expecting DB entry of 255 chars (reasonable value but not a fact) and you receive > 255 later on...
  • diegopau
    diegopau almost 9 years
    Reading on the same google group post, it seems it was a mistake, 4k is the limit for the payload of the message, not the reg id. 255 seems to be the safe limit, also acording to this post.
  • Ahi Tuna
    Ahi Tuna over 8 years
    I did varchar(512) just to be safe :P
  • Omar Alshaker
    Omar Alshaker about 8 years
    This is the payload, not the ID.