gpt4 book ai didi

java - 如何在 Android 中查看和记录 GCM 消息的完整结构?

转载 作者:行者123 更新时间:2023-11-30 03:34:48 25 4
gpt4 key购买 nike

我想调试接收我的应用程序的 GCM 消息,但问题是我无法在 data 数组之外记录字段:collapse key, time-to -live 等。来自服务器的 GCM 消息如下所示:

{
"registration_ids" : ["xyz"],
"data" : {
text: {...}
},
"time_to_live" : 3
},

出于调试目的,我想记录生存时间参数和其他参数。但是当我这样做时:String text = intent.getExtras().getString("text"); 我只能查看里面的数据。如何查看所有 GCM 消息结构?

最佳答案

我不相信你可以。data 之外的参数不是通知负载的一部分。有理由相信它们甚至没有被 GCM 服务器传递给您的应用程序。这些外部参数的唯一目的是告诉 GCM 服务器如何传递消息(是否将其发送到空闲设备,当设备不可用时将其保留在 GCM 服务器中多长时间,是否覆盖旧的未传递消息具有相同的折叠键等...)。

编辑:

Handling Received Data

The com.google.android.c2dm.intent.RECEIVE intent is used by GCM to deliver the messages sent by the 3rd-party server to the application running in the device. If the server included key-pair values in the data parameter, they are available as extras in this intent, with the keys being the extra names. GCM also includes an extra called from which contains the sender ID as an string, and another called collapse_key containing the collapse key (when in use).

从这个引用中,除了 data 中的键/值对之外,您似乎还可以检索 collapse_keysender ID .

关于java - 如何在 Android 中查看和记录 GCM 消息的完整结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16776913/

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