2013-10-01 170 views
2

我没有收到我的Android推送通知。我能够在Android上未收到推送通知

  • 寄存器
  • 接收的设备标识符
  • 推送通知消息GCM设备

我顺利进入通知已发送事件,但上接收任何消息我的设备。推送成功的代码如下:

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

回答

1

确保你已经在android端设置了一切。 https://developer.android.com/google/gcm/gcm.html

除此之外,PushSharp确实有可用的,你可能想获得一个新的版本。 https://github.com/Redth/PushSharp

您可能还想添加一些事件来跟踪并确保没有问题。

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

然后在Android方面,检查的logcat看看是否有消息,未来通过。

即使退一步,并尝试从设备本身发送的推动。 https://developer.android.com/google/gcm/client.html

+0

似乎有一些需要在Android应用程序方面做是为了一旦GCM收到以显示他们手机上。我发现这些消息被推送到GCM和GCM发送给他们,但android应用程序没有处理要显示的消息。感谢您的帮助。 – user1453999