简体   繁体   English

如何在GCM中计算有效载荷限制[python]

[英]How to calculate payload limit in GCM [python]

I am sending messages from google gcm using python. 我正在使用python从Google gcm发送消息。 and GCM having 4kb(4096) limit in payload 和GCM的有效载荷限制4kb(4096)

s = "你好"
u = u"你好"
len(s) # output is 6
len(u) # output is 2 because of unicode 

Now my question is how to count payload size. 现在我的问题是如何计算有效载荷大小。

or 要么

what is google considering for size of payload as unicode or utf-8 ? Google考虑将有效载荷的大小设置为unicode还是utf-8?

Documentation says: 文档说:

Data payload lets developers send up to 4KB of custom key/value pairs. 数据有效载荷使开发人员最多可以发送4KB的自定义键/值对。

so you need to calculate bytes not characters . 所以你需要计算字节而不是字符 In your case your size is 6. 您的大小是6。

这是谷歌GCM的问题确认表格gcm-dev-support由于这个原因,我可以发送12kb有效负载(即使限制为4kb)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM