android GCM registration ID max length

39,428

Solution 1

A google engineer said the registration ID can be up to 4K. Users have observed it is 255 characters.

Solution 2

i think i can help you out with this... i´m working with GCM this week, and my device´s registration ID looks like this:

APA91bHPRgkF3JUikC4ENAHEeMrd41Zxv3hVZjC9KtT8OvPVGJ-hQMRKRrZuJAEcl7B338qju59zJMjw2DELjzEvxwYv7hH5Ynpc1ODQ0aT4U4OFEeco8ohsN5PjL1iC2dNtk2BAokeMCg2ZXKqpc8FXKmhX94kIxQ

163 characters!

i hope this can help you out...

Solution 3

On iOS all my registration tokens look like this:

lhBV25_Znsk:APA91bHFM9nbX-s0py6-ktzgdpP_y85RahdL3OJ4LG4v-jT_9QY8ZbZH8uK-JNO_BDy75b6RfDT-v-j5W0FXIFTif72ckT3kqLNBDNWYSd5AhxYwdJi3Wqfdqqi-wL8F_k1nm2qUS3Ra

(152 chars)

Note the colon after 11 characters. Note also that it has the sequence "APA..." AFTER the colon, however you should use the whole registration token.

Solution 4

There's no official limit for GCM ID, the payload size is 4k when I am writing this. Although, it is safe to assume 255 for GCM ID according to this and the discussion before me.

If it is in database that you are asking the question for, I suggest that you use TEXT.

Share:
39,428
Dahevos
Author by

Dahevos

Updated on July 09, 2022

Comments

  • Dahevos
    Dahevos almost 2 years

    In Google Cloud Messaging, what is exactly the registration ID maximum length?

  • Dahevos
    Dahevos almost 12 years
    thanks, i decided to choose a varchar(250) for the moment (hope Google will not increase the regID over 250 char in time)
  • VaroX
    VaroX almost 12 years
    yeah, i´d do that too... btw, this´ my first C2DM/GCM development... and i´m kinda stuck now... because my device seems to get the registrationID right... and i have a php based server, where a want to send a notification everytime an user adds any content... and this seems to be right as well!!!! BUT! i dont get any notification on my phone/emulator. I check the Google Api Console to see if is there any traffic report... but there´s no data at all!! i´m getting frustrated with this!! do you know something about it? thx!
  • Dahevos
    Dahevos almost 12 years
    check permission in your manifest file. Use thie script linked in my answer
  • loeschg
    loeschg about 11 years
    Mine is 183 characters - 4/19/2013
  • Andrew Westberg - BCSH
    Andrew Westberg - BCSH over 10 years
    This answer is dangerous. Just saw a reg id come in at 205. Blew up in our DB which had a field size of 200. We'll be increasing to 4096.
  • Andrew Westberg - BCSH
    Andrew Westberg - BCSH about 10 years
    My testing suggests that your package name length has an effect on the token size. If you're running into some tokens coming in longer than you have space in your DB, changing to a shorter package name can relieve the issue in some cases.
  • Gaston Sanchez
    Gaston Sanchez almost 10 years
    Right! there is no official limit on the device ID. I think a sane number could be 512. Although maximum length I've come until now is 205, who knows, it could increase.
  • Henry Aloni
    Henry Aloni almost 10 years
    Also here is the explanation why it is 4k : The max size for a registration_id is bounded by the max size for a cookie, which is 4K (4096 bytes). In practice, the tokens are going to be much smaller than that, but you shouldn't rely on this behavior going forward. From groups.google.com/forum/#!topic/android-c2dm/AUGlvmJPyMM
  • user2387149
    user2387149 over 8 years
    I have the same problem and I'm wondering the same thing... has someone figured out this?
  • Lukasz Czerwinski
    Lukasz Czerwinski over 8 years
    The reason GCM didn't work for me was that I uploaded wrong .p12 file to Google server. Make sure that you generate the right one.
  • Magnus Smith
    Magnus Smith about 8 years
    In SQL Server it would be better to use VARCHAR(MAX) because TEXT is a right pain to work with.
  • blackjack
    blackjack about 8 years
    In my new register i got the GCM reg id as like this 0vfNE9qzu8:APA91bEzTKfWMbhyjF736xarAF3i5A2-o2jTHvBqRO3Z6OCdp‌​t5qLvIIi_VymvFVcUIMc‌​hDNUiknexOKGKkEI-zoR‌​TvbXAh3atMPYoh2ROmk3‌​fifrnpH-GWP-a5PYr861‌​Qf6u5jY9uTP
  • Rakib
    Rakib about 8 years
    but what about another guy saying "255 is perferct with varchar. 4k is for the payload, not the reg id." later in the comment? groups.google.com/forum/#!msg/android-gcm/q2PzJTP71TY/…
  • alicanbatur
    alicanbatur almost 8 years
    Do you use GCM for ios?
  • naXa stands with Ukraine
    naXa stands with Ukraine almost 7 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.
  • greatvovan
    greatvovan over 6 years
    APA is an Android token, not iOS.