I have succeeded sending a push message to an iOS device but I'm running into problem with Android. I have been given the GCM API key and the registration id of the device that has the app installed.
However, when I try to send the push message, the NotificationFailed
event is triggered. The Exception I get is of type PushSharp.Android.GcmMessageTransportResponse
and its message is "Invalid Registration". What is it that I am doing wrong?
var push = new PushBroker();
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("AIXXXXXXXXXXXXXXXX"));
push.QueueNotification(new GcmNotification()
.ForDeviceRegistrationId("APAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
.WithJson("{\"alert\":\"Hello World!\",\"badge\":7,\"sound\":\"sound.caf\"}");
push.StopAllServices();