Moja aplikacja odbiera powiadomienia push, gdy aplikacja jest zamknięta. Ale gdy aplikacja jest uruchomiona, nic nie dostaję. Jest to ten sam kod, który użyłem w poprzednich aplikacjach bez żadnych problemów, które były na WindowsPhone8, a nowe aplikacje działają na urządzeniach WindowsPhone 8.1.PUSH nie wyświetla się, gdy aplikacja jest otwarta.
Użyłem tego Push Tutorial podczas tworzenia oryginalnej aplikacji. Mam linię, która mówi: dodaj to, jeśli chcesz otrzymywać powiadomienia, gdy aplikacja jest otwarta.
Jeśli aktualizacja 8.1 dokonała czegoś w powiadomieniach push, które warto poznać. Cokolwiek innego byłoby również docenione.
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];
}
}
}
Proszę pokazać kod. Czy korzystasz z MPNS lub WNS? – Fred
Dodano kod. Innym sposobem jest dodanie modułów obsługi zdarzeń do już istniejącego PushChannel. – Seige
W skrócie, ShellToastNotificationReceived nie uruchamia się. Czyż nie? – fillobotto