Question

I am not receiving my Android Push notifications. I am able to

  • register the device
  • receive a device identifier
  • push the notification message to GCM

I successfully enter into the Notification Sent event, but no message is received on my device. The successful push code is as follows:

string apiKey = "API KEY HERE";
push.RegisterGcmService(new GcmPushChannelSettings(apiKey));

string load = "Hello World";
int count = 2;
string dev = 'device identifier generated for device';
string payload = "{\"alert\":" + "\"" + load + "\"" + ",\"badge\":" + "\"" + count + "\"}";
//IMPORTANT: For Android you MUST use your own RegistrationId here that gets generated within your Android app itself!
GcmNotification note = new GcmNotification().ForDeviceRegistrationId(dev).WithJson(payload);
Was it helpful?

Solution

Make sure you have everything set up on the android side. https://developer.android.com/google/gcm/gcm.html

Besides that, PushSharp does have a new version available that you may want to get. https://github.com/Redth/PushSharp

You may also want to add some events to track and make sure there are no issues.

        push.OnDeviceSubscriptionExpired += new DeviceSubscriptionExpiredDelegate(push_OnDeviceSubscriptionExpired);
        push.OnDeviceSubscriptionChanged += new DeviceSubscriptionChangedDelegate(push_OnDeviceSubscriptionChanged);
        push.OnChannelException += new ChannelExceptionDelegate(push_OnChannelException);
        push.OnNotificationFailed += new NotificationFailedDelegate(push_OnNotificationFailed);
        push.OnNotificationSent += new NotificationSentDelegate(push_OnNotificationSent);

Then on the android side, check logcat to see if any messages are coming through.

Even stepping back and try to send a push from the device itself. https://developer.android.com/google/gcm/client.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top