Подтвердить что ты не робот

Параметры уведомлений тоста в Windows Phone 8.1 Silverlight

Хорошо, поэтому я использую новый ToastNotificationManager в моем проекте 8.1 SL вместо старого ShellToast. ShellToast имел NavigationUri в сообщении тоста, которое делало его очень легким.

В новых тостах вы должны указать параметры запуска самостоятельно в соответствии с этой статьей. Однако похоже, что у 8.1 SL нет события OnLaunched (LaunchActivatedEventArgs args), которое вы должны прослушивать в App.xaml.cs для параметров:

Шаг 2: Обращайтесь к приложению "OnLaunched"

Когда пользователь нажимает на ваш тост или выбирает его прикосновением, связанное приложение запускается, запуская его событие OnLaunched.

Примечание. Если вы не указали строку атрибута запуска в своем тосте и ваше приложение уже работает, когда выбран тост, Событие OnLaunched не запускается.

В этом примере показан синтаксис переопределения OnLaunched событие, в котором вы будете извлекать и действовать в строке запуска поставляемый через уведомление тоста.

protected override void OnLaunched(LaunchActivatedEventArgs args)
{
    string launchString = args.Arguments

    ....
}

Мой код:

// 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 phone.
toast.SuppressPopup = true;

// Send the toast.
ToastNotificationManager.CreateToastNotifier().Show(toast);

Кто-нибудь знает, как это решить? Благодаря

4b9b3361

Ответ 1

Ваша проблема в том, что вы устанавливаете неправильный параметр launch. Вы должны установить его прямо на страницу, на которую хотите перейти.

var toastNavigationUriString = ""#/MainPage.xaml?param1=12345";
var toastElement = ((XmlElement)toastXml.SelectSingleNode("/toast"));
toastElement.SetAttribute("launch", toastNavigationUriString);