I'm using C# and Windows Phone 8.1 as Universal app. I can send notifications from background by this code:
void ShowNotification(string title, string text)
{
ToastTemplateType toastTemplate = ToastTemplateType.ToastText02;
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);
XmlNodeList textElements = toastXml.GetElementsByTagName("text");
textElements[0].AppendChild(toastXml.CreateTextNode(title));
textElements[1].AppendChild(toastXml.CreateTextNode(text));
ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(toastXml));
}
I wanna when user tapped on these notifications in action center, that message I wrote in notification shows on a textBlock in my MainPage but I don't know how can I set a parameter to do this. I used this code in MainPage but parameter is empty:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (e != null && e.Parameter != null)
{
Debug.WriteLine("MainPage.OnNavigatedTo.Parameter: " + e.Parameter.ToString());
}
}
thanks
You need to specify app launch parameters like:
Then in app's onlaunched event, navigate to mainpage with the parameter you get as below: