51

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

rds
  • 26,253
  • 19
  • 107
  • 134
Dahevos
  • 1,495
  • 5
  • 16
  • 26

4 Answers4

54

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

rds
  • 26,253
  • 19
  • 107
  • 134
  • 5
    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 https://groups.google.com/forum/#!topic/android-c2dm/AUGlvmJPyMM – Henry Aloni Jul 16 '14 at 17:57
  • 4
    but what about another guy saying __"255 is perferct with varchar. 4k is for the payload, not the reg id."__ later in the comment? https://groups.google.com/forum/#!msg/android-gcm/q2PzJTP71TY/YUKmCjx5kKwJ – Rakib Mar 13 '16 at 13:08
  • 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. – naXa stands with Ukraine Jun 13 '17 at 14:01
11

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

VaroX
  • 430
  • 4
  • 17
  • 1
    thanks, i decided to choose a varchar(250) for the moment (hope Google will not increase the regID over 250 char in time) – Dahevos Jul 16 '12 at 10:59
  • 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! – VaroX Jul 16 '12 at 11:04
  • check permission in your manifest file. Use thie script linked in my answer – Dahevos Jul 16 '12 at 13:48
  • Mine is 183 characters - 4/19/2013 – loeschg Apr 19 '13 at 20:53
  • 25
    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 Jan 20 '14 at 20:51
  • 2
    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. – Andrew Westberg - BCSH Apr 03 '14 at 14:11
  • 1
    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. – Gaston Sanchez Jun 19 '14 at 17:57
  • In my new register i got the GCM reg id as like this 0vfNE9qzu8:APA91bEzTKfWMbhyjF736xarAF3i5A2-o2jTHvBqRO3Z6OCdpt5qLvIIi_VymvFVcUIMchDNUiknexOKGKkEI-zoRTvbXAh3atMPYoh2ROmk3fifrnpH-GWP-a5PYr861Qf6u5jY9uTP – blackjack Feb 04 '16 at 08:53
4

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.

Lukasz Czerwinski
  • 13,499
  • 10
  • 55
  • 65
2

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.

Mayank
  • 1,364
  • 1
  • 15
  • 29