I've recently implemented PushSharp into an application but for the life of me I can't figure out why the notification isn't appearing on the device.
The following is a method that put together to test the behaviour:
private void SendPushNotification()
{
var push = new PushBroker();
//Wire up the events for all the services that the broker registers
push.OnNotificationSent += NotificationSent;
push.OnChannelException += ChannelException;
push.OnServiceException += ServiceException;
push.OnNotificationFailed += NotificationFailed;
push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
push.OnDeviceSubscriptionChanged += DeviceSubscriptionChanged;
push.OnChannelCreated += ChannelCreated;
push.OnChannelDestroyed += ChannelDestroyed;
push.RegisterGcmService(new GcmPushChannelSettings("My-API-Key-here"));
push.QueueNotification(new GcmNotification().ForDeviceRegistrationId("MyReallyLongRegisteredDeviceKeyHere")
.WithJson(@"{""alert"":""Hello World!"",""badge"":7,""sound"":""sound.caf""}"));
//Stop and wait for the queues to drains
push.StopAllServices();
}
This method is called immediately upon application start, so I would expect that I get a notification straight away which I don't.
What else is strange is that the event OnNotificationSent
is called which would indicate that the message has gone through.
Is there anything else I need to configure in order for this to work? The documentation states that the sender id, package name and api key are required in order to send notifications
all but the api key are used though.
Any help would be greatly appreciated.