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

后端 未结 3 1759
南笙
南笙 2020-11-30 05:40

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 s

3条回答
  •  旧时难觅i
    2020-11-30 06:18

    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)

提交回复
热议问题