In Google Cloud Messaging, what is exactly the registration ID maximum length?
-
1Possibly, 256 bytes is a safe value for storage. – swiftBoy Nov 29 '13 at 06:02
4 Answers
A google engineer said the registration ID can be up to 4K.
Users have observed it is 255 characters.

- 26,253
- 19
- 107
- 134
-
5Also 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
-
4but 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
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...

- 430
- 4
- 17
-
1thanks, 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
-
-
25This 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
-
2My 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
-
1Right! 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
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.

- 13,499
- 10
- 55
- 65
-
I have the same problem and I'm wondering the same thing... has someone figured out this? – user2387149 Aug 11 '15 at 20:17
-
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. – Lukasz Czerwinski Aug 12 '15 at 21:31
-
-
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.

- 1,364
- 1
- 15
- 29
-
1In SQL Server it would be better to use VARCHAR(MAX) because TEXT is a right pain to work with. – Magnus Smith Feb 01 '16 at 23:02