Okej, więc używam nowego ToastNotificationManager w moim projekcie 8.1 SL zamiast starego ShellToast. ShellToast miał NavigationUri na toastowej wiadomości, dzięki czemu było naprawdę łatwe.Parametry powiadomienia toastowego w Windows Phone 8.1 Silverlight
W nowych toastach należy samodzielnie określić parametry uruchamiania zgodnie z artykułem this. Jednak wydaje się, jakby 8.1 SL nie posiada zdarzenie OnLaunched (LaunchActivatedEventArgs args) ci mają słuchać w App.xaml.cs dla parametrów:
Krok 2: Uchwyt „OnLaunched” aplikacja na zdarzenie
Gdy użytkownik kliknie na toast lub wybierze go za pomocą dotyku, uruchomiona zostaje powiązana aplikacja , uruchamiając zdarzenie OnLaunched.
Uwaga Jeśli w tostach nie zostanie podany ciąg atrybutu uruchamiania, a aplikacja jest już uruchomiona po wybraniu tostów, zdarzenie OnLaunched nie zostanie wywołane.
W tym przykładzie przedstawiono składnię zastąpienia zdarzenia OnLaunched , w którym można pobrać i uruchomić ciąg znaków dostarczony za pośrednictwem powiadomienia toast.
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
string launchString = args.Arguments
....
}
Mój kod:
// Using the ToastText02 toast template.
ToastTemplateType toastTemplate = ToastTemplateType.ToastText02;
// Retrieve the content part of the toast so we can change the text.
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);
//Find the text component of the content
XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");
// Set the text on the toast.
// The first line of text in the ToastText02 template is treated as header text, and will be bold.
toastTextElements[0].AppendChild(toastXml.CreateTextNode("Heading"));
toastTextElements[1].AppendChild(toastXml.CreateTextNode("Body"));
// Set the duration on the toast
IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
((XmlElement)toastNode).SetAttribute("duration", "long");
//Launch params
string paramString = "{\"type\":\"toast\",\"param1\":\"12345\"}";
((XmlElement)toastXml.SelectSingleNode("/toast")).SetAttribute("launch", paramString);
// Create the actual toast object using this toast specification.
ToastNotification toast = new ToastNotification(toastXml);
// Set SuppressPopup = true on the toast in order to send it directly to action center without
// producing a popup on the user's phone.
toast.SuppressPopup = true;
// Send the toast.
ToastNotificationManager.CreateToastNotifier().Show(toast);
Ktoś wie jak rozwiązać ten problem? Dzięki
Możesz podać toast za pomocą parametru nawigacji bezpośrednio. Zdobędę szczegóły, kiedy jutro wrócę do pracy. Dziwne, że nie udokumentowaliśmy tego poprawnie. –
Dzięki nie możemy się doczekać! :) – robertk
Jeśli używasz ToastNotificationManager w Silverlight 8.1, co używasz zamiast zdarzenia OnLoaded, ponieważ SL nie ma tego w App.xaml? Mam go w wersji OnNavigatedTo, ale wydaje się, że dwa razy, gdy kliknięto toast, nazywa się go. Używam odpowiedzi do wyzwalacza obciążenia poniżej. – gcoleman0828