我使用 PushSharp 发送推送通知。如 GitHub 上的 Redth 文档中所述,我在接收委托方法中的响应时遇到问题。
因此,在我发送特定消息的 10 个 GCM 注册 ID 中,我只收到 9 个响应。我需要这种响应以确保在返回规范 ID 的情况下我应该能够相应地更新我的数据库。
这种行为是设计使然(即不等待来自 GCM 的所有响应)导致很少有响应被丢弃吗?
下面是我的代码片段,以便更好地理解
//创建我们的推送服务代理
//Create our push services broker
var broker = new PushBroker();
broker.OnNotificationSent += new NotificationSentDelegate(NotificationSent);
broker.OnNotificationFailed += new PushSharp.Core.NotificationFailedDelegate(NotificationFailed);
broker.OnChannelException += new ChannelExceptionDelegate(ChannelException);
broker.OnServiceException += new ServiceExceptionDelegate(ServiceException);
broker.OnDeviceSubscriptionChanged += new DeviceSubscriptionChangedDelegate(DeviceSubscriptionChanged);
broker.OnDeviceSubscriptionExpired += new PushSharp.Core.DeviceSubscriptionExpiredDelegate(DeviceSubscriptionExpired);
broker.OnChannelCreated += new ChannelCreatedDelegate(ChannelCreated);
broker.OnChannelDestroyed += new ChannelDestroyedDelegate(ChannelDestroyed);
//---------------------------
// ANDROID GCM NOTIFICATIONS
//---------------------------
broker.RegisterGcmService(new GcmPushChannelSettings(senderID, senderAuthToken, applicationIdPackageName));
GcmNotification gcm = new GcmNotification();
gcm.RegistrationIds.Add(deviceRegistrationId1);
gcm.RegistrationIds.Add(deviceRegistrationId2);
//and so on
gcm.WithJson("{\"Test\":\"" + notificationMsg + "\",\"badge\":7,\"sound\":\"sound.caf\"}");
//Stop and wait for the queues to drains
broker.StopAllServices(true);
//<
如果我在这个实现中遗漏了什么,请告知。提前致谢