Firebase – How much is the maximum length of the FCM registration ID token?

With the “new” Firebase Cloud Messaging, I want to reliably save the client device registration_id token to the local server database so that the server software can send them push notifications.

Which smallest database field size should I use to store 100% of client registration tokens?

I found two different libraries that use TextField and VarChar(255), but the maximum length is not clearly defined. Also, I want the server code to perform a quick check when receiving the token to make sure they “look “Correct-what is a good minimum length and character set to check?

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

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

Emphasis that the format may change in the future, I recommend keeping it safe And exceed the usual maximum length (as mentioned above). Because the format and length of the registration token may also be different.

For the usual length and characters, you can refer to these two answers, the latter is more clear :

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\-\_]*< /li>
  • every regID contains one or both of “delimiters”: – (minus) or _ (underline)

Use “New” Firebase Cloud Messaging, I want to reliably save the client device registration_id token to the local server database so that the server software can send them push notifications.

Which minimum should I use Is the database field size to hold 100% of the client registration token?

I found two different libraries that use TextField and VarChar(255), but the maximum length is not clearly defined. Also, I want the server code to perform a quick check when receiving the token to make sure they “look “Correct-what is a good minimum length and character set to check?

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

It is emphasized that the format may change in the future part, I suggest to stay safe and exceed the usual maximum (as mentioned above) length .Because the format and length of the registration token may also be different.

For the usual length and characters, you can refer to these two answers, the latter is more clear:

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)

Leave a Comment

Your email address will not be published.