使用PushSharp发送邮件时无法获取所有事件

时间:2014-05-20 15:57:26

标签: push-notification google-cloud-messaging pushsharp

我使用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);

//<

请告知我是否遗漏了此实施中的内容。 提前致谢

1 个答案:

答案 0 :(得分:0)

当您将代理与PushSharp代理关联而不是您自己的代理时,您没有注册以查看失败的通知:

 broker.OnNotificationFailed += new    PushSharp.Core.NotificationFailedDelegate(NotificationFailed);

应符合您的要求:

 broker.OnNotificationSent += new NotificationSentDelegate(NotificationSent);