2013-10-11 3 views
1

Windows Phone 푸시 알림을 개발하는 동안 문제가 발생했습니다. ChannelUriUpdated 이벤트가 전혀 트리거되지 않았습니다. 나는 다음과 같은 ConnectionStatusChanged 이벤트를 등록 할 때 :Windows Phone 8 ChannelUriUpdated가 실행되지 않았습니다.

void pushChannel_ConnectionStatusChanged(object sender, NotificationChannelConnectionEventArgs e) 
    { 
     var state = e.ConnectionStatus; 
    } 

그리고 ConnectionStatusChanged 지속적으로 실행됩니다. "state"값은 Connected와 Disconnected를 교대로 사용합니다. 어떤 도움을 이해할 수있을 것이다 MSDN Push Notification Sample Code

:

나는 코드를 사용합니다. 코드 아래 링크 아래

답변

0

Follw는

How to send and receive toast notifications for Windows Phone

Push Notification for windows phone

사용

HttpNotificationChannel pushChannel; 

      // The name of our push channel. 
      string channelName = "ToastSampleChannel"; 

      InitializeComponent(); 

      // Try to find the push channel. 
      pushChannel = HttpNotificationChannel.Find(channelName); 

      // If the channel was not found, then create a new connection to the push service. 
      if (pushChannel == null) 
      { 
       pushChannel = new HttpNotificationChannel(channelName); 

       // Register for all the events before attempting to open the channel. 
       pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated); 
       pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred); 

       // Register for this notification only if you need to receive the notifications while your application is running. 
       pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived); 

       pushChannel.Open(); 

       // Bind this new channel for toast events. 
       pushChannel.BindToShellToast(); 

      } 
      else 
      { 
       // The channel was already open, so just register for all the events. 
       pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated); 
       pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred); 

       // Register for this notification only if you need to receive the notifications while your application is running. 
       pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived); 

       // Display the URI for testing purposes. Normally, the URI would be passed back to your web service at this point. 
       System.Diagnostics.Debug.WriteLine(pushChannel.ChannelUri.ToString()); 
       MessageBox.Show(String.Format("Channel Uri is {0}", 
        pushChannel.ChannelUri.ToString())); 

      } 
     } 

이 당신을 위해 작동 희망 나를 위해 그 일 ... 여기에 코멘트보다 쿼리의 경우 ....

+0

게시 한 코드는 똑같은 위트입니다. h 내가 사용한 MSDN 푸시 알림 샘플 코드. – Joel