GCM - Max length for Registration ID
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
Related videos on Youtube
Raj Chaudhari
Updated on August 10, 2020Comments
-
Raj Chaudhari over 3 years
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?
-
Alastair Pitts over 11 yearspossible duplicate of android GCM registration ID max length
-
-
Jakob Alexander Eichler over 11 yearsso the max gcmId length is 512 characters?
-
azgolfer over 11 yearsThat'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 almost 11 yearsThis refers to the notification payload, not the registration id.
-
Andrew Westberg - BCSH about 10 yearsYour 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 about 10 yearsUsing "text" type in your MySql table won't let you create an index for it.
-
Stan about 10 yearswhat 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. almost 10 yearsAnother thread, same answer from a Google developer: groups.google.com/forum/#!topic/android-c2dm/AUGlvmJPyMM Just as confirmation...
-
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 over 9 years@Pius For indexing on server's DB like MySQL?
-
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 over 9 yearsomg. Can't you understand - its about storing tons of user's GCM IDs on server and indexing them?
-
mwm about 9 yearsthey 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 almost 9 yearsReading 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 over 8 yearsI did varchar(512) just to be safe :P
-
Omar Alshaker about 8 yearsThis is the payload, not the ID.