2014-10-28 2 views
13

응용 프로그램을 닫으면 내 응용 프로그램이 푸시 알림을 수신합니다. 하지만 앱이 실행 중일 때 나는 아무것도 얻지 못합니다. 이 코드는 WindowsPhone8에 있던 문제가없는 이전 응용 프로그램과 WindowsPhone8.1 장치에서 실행중인 새 응용 프로그램에서 사용한 코드와 같습니다.응용 프로그램이 열려있을 때 PUSH가 표시되지 않습니다.

원본 앱을 만들 때 Push Tutorial을 사용했습니다. 앱이 열려있는 동안 알림을 받고 싶다면이 내용을 추가하는 줄이 있습니다.

8.1 업데이트가 알리겠습니다 푸시 알림에 뭔가를 한 경우. 다른 것은 또한 평가 될 것입니다.

HttpNotificationChannel pushChannel; 
string channelName = "PushChannel"; 
pushChannel = HttpNotificationChannel.Find(channelName); 
//Push Notifications 
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... 



void PushChannel_ShellToastNotificationReceived(object sender, 
                 NotificationEventArgs e) 

{ 
    string relativeUri = string.Empty; 

    // Parse out the information that was part of the message. 
    foreach (string key in e.Collection.Keys) 

    { 
     if (string.Compare(
     key, 
     "wp:Param", 
     System.Globalization.CultureInfo.InvariantCulture, 
     System.Globalization.CompareOptions.IgnoreCase) == 0) 

     { 
      relativeUri = e.Collection[key]; 
     } 


    } 
} 
+0

일부 코드를 표시하십시오. MPNS 또는 WNS를 사용하고 있습니까? – Fred

+0

코드가 추가되었습니다. else는 이벤트 핸들러를 기존의 PushChannel에 추가하는 것입니다. – Seige

+0

간단히 말해서, ShellToastNotificationReceived가 실행되지 않습니다. 그렇지 않니? – fillobotto

답변

2

롭 캐플란은 :

토스트 앱이 포 그라운드에있을 때 표시 할 것으로 예상되지 않습니다. 필요한 경우 앱에 자체 UI가 표시되어야합니다 (스 니펫에는 아무 것도 표시되지 않음). ShellToastNotificationReceived 이벤트는 다음과 같습니다. 토스트 알림이 도착했을 때 표시됩니다. 축배를 기대할 때 ShellToastNotificationReceived가 제기되지 않았 음을 확인할 수 있습니까? 그것은해야한다. 디버거에 등록되어 있거나 디버거에서 수신되었는지 확인할 수 있습니까? msdn.microsoft.com/en-us/library/windows/apps/...

나를 참조 : 오픈 응용 프로그램은 푸시를 받았을 때

8.1 업데이트하기 전에, 토스트 여전히 보여줄 것입니다. 방금 테스트를했는데 "PushChannel_ShellToastNotificationReceived"이벤트가 여전히 실행 중이지만 표시되지 않았습니다. 나는 이것이 내가 다른 것을 다룰 필요가 있다는 것을 의미한다고 생각한다. 만약 당신이 그것을 대답으로 바꾸고 싶다면 현상금을 수여 할 수 있습니다.

관련 문제