Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
587 views
in Technique[技术] by (71.8m points)

firebase - What is the maximum length of an FCM registration ID token?

Working with the "new" Firebase Cloud Messaging, I would like to reliably save client device registration_id tokens to the local server database so that the server software can send them push notifications.

What is the smallest size of database field that I should use to save 100% of client registration tokens generated?

I have found two different libraries that use TextField and VarChar(255) but nothing categorically defining the max length. In addition, I would like the server code to do a quick length check when receiving tokens to ensure they "look" right - what would be a good min length and set of characters to check for?

question from:https://stackoverflow.com/questions/39959417/what-is-the-maximum-length-of-an-fcm-registration-id-token

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think this part of FCM is still the same as GCM. Therefore, you should refer to this answer by @TrevorJohns:

The documentation doesn't specify any pattern, therefore any valid string is allowed. The format may change in the future; please do not validate this input against any pattern, as this may cause your app to break if this happens.

As with the "registration_id" field, the upper bound on size is the max size for a cookie, which is 4K (4096 bytes).

Emphasizing on the The format may change in the future part, I would suggest to stay safe and have a beyond the usual max (mentioned above) length. Since the format and length of a registration token may also vary.

For the usual length and characters, you can refer to these two answers the latter being much more definitive:

I hasn't seen any official information about format of GCM registrationId, but I've analyzed our database of such IDs and can make following conclusions:

  • in most cases length of a registrationID equals 162 symbols, but can be variations to 119 symbols, maybe other lengths too;
  • it consists only from this chars: [0-9a-zA-Z-\_]*
  • every regID contains one or both of "delimiters": - (minus) or _ (underline)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...