FCM注册ID令牌的最大长度是多少? [英] What is the maximum length of an FCM registration ID token?

查看:1867
本文介绍了FCM注册ID令牌的最大长度是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用新Firebase云消息传递,我想可靠地将客户端设备 registration_id 标记保存到本地服务器数据库,以便服务器软件可以发送它们通知。

我应该使用哪个数据库字段的最小大小来保存100%的客户端注册令牌?



我发现了两个不同 使用 TextField的图书馆 VarChar(255),但没有明确定义最大长度。另外,我希望服务器代码在收到令牌时做一个快速的检查,以确保它们看起来是正确的 - 什么是一个很好的最小长度和一组字符来检查?
<解决方案我认为这部分FCM仍然是GCM。因此,您应该参考@TrevorJohns的回答


文档没有指定任何模式,因此任何有效的字符串都是允许的。 格式可能在将来改变;请不要对任何模式验证此输入,因为如果发生这种情况,这可能会导致您的应用程序中断。

registration_id字段的大小上限是cookie的最大大小,即4K(4096字节)。




强调格式可能在将来改变部分,我建议保持安全,并超出通常的最大(上述)长度。由于注册标记的格式和长度也可能有所不同。


对于通常的长度和字符,可以参考这些两个 答案 后者更明确
$ b


我还没有看到有关GCM registrationId格式的任何官方信息,但是我已经分析了这些ID的数据库并且可以得出以下结论:在大多数情况下,注册ID的长度等于 162 符号,但是可以是变化的至 119 符号,也可能是其他长度;

  • 只包含这个字符: [0-9a-zA-Z\每个regID包含一个或两个分隔符: - (减号)或_(下划线)



  • 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?

    解决方案

    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)

    这篇关于FCM注册ID令牌的最大长度是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆