2015-09-10 24 views
0

我使用pushsharp的窗口電話的標準推送通知碼。 我收到設備上的通知。但問題是,我得到多個回調爲每個事件。例如,對於一個通知,我得到5個回叫創建通道,發送通知等。一個通知pushsharp窗口電話的多個回調

請幫助我,我在哪裏做錯了。

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\":\"[email protected]\",\"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); 
+0

有誰對此有任何想法? –

+0

任何人都可以使用上面的代碼並重現問題。如果有人能解決這個問題,請幫助我 –

回答

0

我從支持團隊解決方案,

請不要RegisterWindowsService()(或RegisterWindowsPhoneService())當您想發送只有一種通知(WindowsToastNotification(或相當WindowsPhoneToastNotification)在你的情況)。這些方法在內部爲所有類型的通知進行多次註冊。再加上另一個bug - 你會得到N個回調而不是一個回調。

使用泛型RegisterService(或者說RegisterService)。

基於上述溶液我已經使用以下代碼登記:

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