I'm trying to send a toast notification with a parameter to a Windows Phone 8.1 device, so when a user taps on the toast the app will show a particular page within the app, as it described in this MSDN article https://msdn.microsoft.com/library/windows/apps/jj662938(v=vs.105).aspx
This is a snippet that I use to add a parameter:
<wp:Param>?cmd=command1 </wp:Param>
this how I read it in the app:
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e){
base.OnNavigatedTo(e);
string strVal1 = this.NavigationContext.QueryString["cmd"];
}
After making these changes it works correctly, but only for this first notification. In all subsequent notifications the value of the parameter read within the app is same as it was in the first notification, no matter what I've sent from the server.
Here is an example:
- I'm sending a notification to device that has with this parameter in the notification payload:
<wp:Param>?cmd=command1 </wp:Param>
The value in this.NavigationContext.QueryString("cmd") is command1, as it should be. - Then I send a second notification with this parameter parameter
<wp:Param>?cmd=command2 </wp:Param>
the cmd's value in the this.NavigationContext.QueryString("cmd") is still returned as "command1" instead of command2 as it should be. And it works like that for all subsequent notifications until I force-restart the app.
Here is what I've tried:
- Checked the Uri value in the NavigationEventArgs argument of the OnNavigatedTo event and it's same as what I see in the NavigationContext.
- Double checked notification payload sent from the server (it's correct)
- Checked msdn/stackoverflow/google.
- Checked on both 8.1 emulator and the device (it works the same)
Questions:
- Do I have to do something in the app (idk, clear NavigationContext or something), so it will be different for the next notification?
- Does anyone actually has a live-app that uses partial arguments (not server-driven navigation with full url, but a partial url passed to the app + corresponding navigation from within the app) and it works for multiple subsequent notifications?