簡體   English   中英

在Android上未收到推送通知

[英]Not receiving Push Notifications on Android

我沒有收到我的Android Push通知。 我能夠

  • 注冊設備
  • 接收設備標識符
  • 將通知消息推送到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);

確保您已在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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM