在Android上未接收推送通知
我没有收到Android推送通知。我能在Android上未接收推送通知,android,push-notification,pushsharp,Android,Push Notification,Pushsharp,我没有收到Android推送通知。我能 注册设备 接收设备标识符 将通知消息推送到GCM 我已成功进入“已发送通知”事件,但在我的设备上未收到任何消息。成功的推送代码如下所示: string apiKey = "API KEY HERE"; push.RegisterGcmService(new GcmPushChannelSettings(apiKey)); string load = "Hello World"; int count = 2; string dev = 'device
- 注册设备
- 接收设备标识符
- 将通知消息推送到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端设置好了一切。 除此之外,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以查看是否有消息通过
甚至退一步尝试从设备本身发送推送。
似乎需要在android应用程序端执行一些操作,以便在GCM接收到信息后将其显示在手机上。我发现消息被推送到了GCM,GCM发送了消息,但android应用程序没有处理消息以供显示。谢谢你的帮助。