【问题标题】:Multiple callback for one notification pushsharp window phone一个通知推送窗口电话的多个回调
【发布时间】:2015-09-10 13:28:50
【问题描述】:

我正在使用 pushsharp 为窗口电话使用标准推送通知代码。 我在设备上收到通知。但问题是每个事件我都会收到多个回调。例如,对于一个通知,我会收到 5 个用于创建通道、通知发送等的回调。

请帮助我哪里做错了。

 var push = new PushBroker();

        push.OnChannelCreated += push_OnChannelCreated;
        push.OnChannelDestroyed += push_OnChannelDestroyed;
        push.OnChannelException += push_OnChannelException;
        push.OnDeviceSubscriptionChanged += push_OnDeviceSubscriptionChanged;
        push.OnDeviceSubscriptionExpired += push_OnDeviceSubscriptionExpired;
        push.OnNotificationFailed += push_OnNotificationFailed;
        push.OnNotificationRequeue += push_OnNotificationRequeue;
        push.OnNotificationSent += push_OnNotificationSent;
        push.OnServiceException += push_OnServiceException;

        push.RegisterWindowsService(new WindowsPushChannelSettings("NotificationFra",
           "ms-app://s-1-15-2-", "bJl6kdPqXWtOclINfKNC"));
        //Fluent construction of a Windows Toast Notification
        push.QueueNotification(new WindowsToastNotification().WithLaunch("{\"message\":\"Hi PushNotification\",\"messageToken\":\"AbCD1A3@\",\"notificationType\":3}")
            .AsToastText01("Notification Test for Daily alerts intrade FTD MTD ")
            .ForChannelUri("https://hk2.notify.windows.com/?token=AwYAAAA%2b21ScKkaVZhp5vwRRPn7DWlEqvzKmTXy%2bNfcONUzq9PeglhxTLlD06%2fiLcgyuu9BbdeuY8Pgl"));

        push.StopAllServices(waitForQueuesToFinish: true);

【问题讨论】:

  • 有人知道吗?
  • 任何人都可以使用上面的代码并重现问题。如果有人可以解决此问题,请帮助我

标签: c# windows-phone-8 pushsharp


【解决方案1】:

我从支持团队那里得到了解决方案,

当您只想发送一种通知(WindowsToastNotification(或者更确切地说是 WindowsPhoneToastNotification))时,请不要 RegisterWindowsService()(或 RegisterWindowsPhoneService())。这些方法在内部对所有类型的通知进行多次注册。再加上另一个错误 - 你得到 N 个回调而不是一个。

使用通用 RegisterService(或者更确切地说 RegisterService)。

基于上述解决方案,我使用以下代码进行注册:

    var channel = new WindowsPushChannelSettings("NotificationFra", "ms-app://s-1-15-2-3763039301-", "bJl6kdPqXWtOclINfKNC");
        push.RegisterService<WindowsToastNotification>(new WindowsPushService(channel));

【讨论】:

    猜你喜欢
    • 2023-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-24
    • 1970-01-01
    • 2014-06-06
    相关资源
    最近更新 更多