gpt4 book ai didi

android - 使用 Android GCM,您可以使用深度 JSON 'data' 字段吗?

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:07:46 25 4
gpt4 key购买 nike

也就是能不能发

{
"registration_ids": ["whatever", ...],
"data": {
"foo": {
"bar": {
"baz": [42]
}
}
}
}

或者 GCM 请求的“数据”成员是否仅限于一级键值对?我问 b/c 谷歌文档 [1] 中的措辞暗示了限制,其中“数据”是:

A JSON object whose fields represents the key-value pairs of the message's payload data. If present, the payload data it will be included in the Intent as application data, with the key being the extra's name. For instance, "data":{"score":"3x1"} would result in an intent extra named score whose value is the string 3x1 There is no limit on the number of key/value pairs, though there is a limit on the total size of the message. Optional.

[1] http://developer.android.com/guide/google/gcm/gcm.html#request

最佳答案

刚刚自己做了一个测试,证实了我的猜想。

使用此负载向我自己发送一个 GCM:

{
"registration_ids": ["whatever", ...],
"data": {
"message": {
"bar": {
"baz": [42]
}
}
}
}

我的客户收到它并额外解析“消息” Intent :

handleMessage - message={        "bar": {          "baz": [42]        }      }  

因此您确实可以对数据键的值进行进一步的 JSON 解析。

关于android - 使用 Android GCM,您可以使用深度 JSON 'data' 字段吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11378004/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com