[英]Google Cloud Messaging - is there a way to see list of all sent (or queued) notifications?
We have a strange issue: We use PushSharp to send out notifications to Android devices, and the logs say Notification sent
, but none are received on the device. 我们遇到一个奇怪的问题:我们使用PushSharp向Android设备发送通知,日志显示已
Notification sent
,但设备上没有收到Notification sent
。 If I change the Registration ID (replacing a character with something else), I do get "Invalid token" error, so I believe my requests make it to the server. 如果我更改注册ID(用其他东西替换一个字符),我会收到“无效令牌”错误,所以我相信我的请求会进入服务器。
I'm wondering if there is a way to see a log of all sent (and/or queued) notifications somewhere on Google server , or if it's possible to enable such logging. 我想知道是否有办法在Google服务器上的某处查看所有已发送(和/或排队)通知的日志,或者是否可以启用此类日志记录。
Basically - How can I troubleshoot notification delivery? 基本上 - 我如何解决通知传递问题?
The GCM server returns a response for each message you send to it. GCM服务器为您发送给它的每条消息返回响应。 That message tells you whether the message was accepted or rejected by the server (it doesn't tell whether it was actually delivered to the device), and also specifies the type of error if any.
该消息告诉您该消息是被服务器接受还是拒绝(它不会告诉它是否实际传送到设备),并且还指定了错误类型(如果有的话)。
PushSharp
probably reads this response and notifies about errors (such as the "Invalid token" error you got when you used an invalid registration ID). PushSharp
可能会读取此响应并通知有关错误(例如,使用无效注册ID时出现的“无效令牌”错误)。
If you don't see any errors, the problem is probably in your client application (either in the manifest or in the code that receives the GCM messages). 如果您没有看到任何错误,则问题可能出在您的客户端应用程序中(无论是在清单中还是在接收GCM消息的代码中)。
well, actually it turns out to be tricky. 好吧,实际上事实证明是棘手的。 As per PushSharp documentation I was using the following code to send notifications:
根据PushSharp文档,我使用以下代码发送通知:
push.QueueNotification(new GcmNotification().ForDeviceRegistrationId("DEVICE REGISTRATION ID HERE")
.WithJson(@"{""alert"":""Hello World!"",""badge"":7,""sound"":""sound.caf""}"));
and that was a mistake :) Google needs me to use "message" and "title" fields for notification body message and title respectively. 这是一个错误:)谷歌需要我分别使用“消息”和“标题”字段的通知正文消息和标题。 As soon as I changed code to the following, it started to work:
一旦我将代码更改为以下内容,它就开始工作:
push.QueueNotification(new GcmNotification().ForDeviceRegistrationId("DEVICE REGISTRATION ID HERE")
.WithJson(@"{""message"":""Hello World!"",""title"":""your app name""}"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.