0

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. 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.

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.

Basically - How can I troubleshoot notification delivery?

Eran
  • 387,369
  • 54
  • 702
  • 768
avs099
  • 10,937
  • 6
  • 60
  • 110

2 Answers2

2

The GCM server returns a response for each message you send to it. 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).

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).

Eran
  • 387,369
  • 54
  • 702
  • 768
  • technically that answers my question - but I still would like to keep my own answer because for me (first-time user of GCM) it was very unclear why push notification is not displayed on the screen. Thanks! – avs099 Dec 09 '13 at 22:59
0

well, actually it turns out to be tricky. As per PushSharp documentation I was using the following code to send notifications:

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""}"));
avs099
  • 10,937
  • 6
  • 60
  • 110
  • 3
    Google doesn't need you to use "message" and "title". The person that wrote the application you are sending the notification to is probably expecting these fields. You can send whatever fields you wish with whatever names and values (assuming you don't exceed 4k) as long as the client side developer handles those fields. – Eran Dec 06 '13 at 23:12