응용 프로그램을 닫으면 내 응용 프로그램이 푸시 알림을 수신합니다. 하지만 앱이 실행 중일 때 나는 아무것도 얻지 못합니다. 이 코드는 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];
}
}
}
일부 코드를 표시하십시오. MPNS 또는 WNS를 사용하고 있습니까? – Fred
코드가 추가되었습니다. else는 이벤트 핸들러를 기존의 PushChannel에 추가하는 것입니다. – Seige
간단히 말해서, ShellToastNotificationReceived가 실행되지 않습니다. 그렇지 않니? – fillobotto