正确格式化GCM通知?

时间:2013-12-19 11:02:58

标签: android push-notification toast google-cloud-messaging

我目前正在尝试使用其示例应用程序“留言簿”的Google云消息服务。 https://developers.google.com/cloud/samples/mbs/

我正在尝试发送通知,这些通知应该在屏幕上显示为一个简单的“你好”吐司约5秒。从项目设置页面(如图所示)这样做。也许我误解了这是为了什么。 settings screen, allows me to broadcast a message to all

然而,我尝试通过fiddler2手动执行此操作会导致guestbook客户端应用程序崩溃,而不是让屏幕上的目标Toast闪烁。

以下是我用于尝试推送通知的POST请求的示例 my attempts to push a notification to my registered device

我还做了上面的其他变体,其中包含了“topicId:_broadcast”无济于事。

格式化中有什么东西我错了吗?或者我应该包含的信息缺失。

1 个答案:

答案 0 :(得分:1)

你的格式有点不对劲。它应该是:

{
  "registration_ids":["xxx", "yyy"],
  "data": {
    "message": "test",
    "duration": "5"
  }
}