Windows Phone will navigate to a specific page in the app when Toast's notification is heard
I want to open a specific page in a Windows Phone app when a user clicks on a received toast notification. I am guessing that there might be an event handler for it and I can navigate that page on that page inside that handler. I'm not really sure about that. It's just an estimate. There may be certain solutions that you can suggest.
source to share
string toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<wp:Notification xmlns:wp=\"WPNotification\">" +
"<wp:Toast>" +
"<wp:Text1>" + sampleText+ "</wp:Text1>" +
"<wp:Text2>" + sampleText+ "</wp:Text2>" +
"<wp:Param>/Page.xaml</wp:Param>" +
"</wp:Toast> " +
"</wp:Notification>";
Here you can replace /Page.xaml with the name of the page you want to navigate to.
source to share
In your notification event handler, just add this from the uri of the page you want to navigate to. Be sure to replace "SomePage.xaml" accordingly.
NavigationService.Navigate(new Uri("/SomePage.xaml", UriKind.Relative));
Try looking at the bottom of the MSDN Toast Property Page . It looks like clicking on the default notification launches your app.
One way to do this is to set a parameter like ToastSetting that is toggled to "true" with the event toast.Show();
. Then, the event OnNavigatedTo
has an if / else statement that looks for your ToastSetting to be "true". Like this:
//Did toast.Show(); fire?
If (appSettings.ToastSetting)
{
//reset the toast setting
appSettings.ToastSetting == false;
//navigate to different page
NavigationService.Navigate(new Uri("/SomePage.xaml", UriKind.Relative));
}
else
{
//do nothing
}
source to share