5

I have a case in my app where I need to send a push notification to a user device when the application is offline and appears as a toast notification.

I need when the user clicks on the toast message to navigate to a specific page in my application depending on the message. I know that this is available in toast notifications but can I send parameters from my server to the toast to determine the page?

Eran
  • 387,369
  • 54
  • 702
  • 768
Ahmed Emad
  • 550
  • 2
  • 7
  • 25
  • Take a look at [this question](http://stackoverflow.com/questions/11153113/can-i-tell-if-a-user-opened-my-app-by-tapping-on-a-toast-notification) – New Dev Aug 13 '13 at 12:25

1 Answers1

15

Of course you can.

The XML of the toast notification you send from your server looks like this:

 <?xml version="1.0" encoding="utf-8"?>
 <wp:Notification xmlns:wp="WPNotification">
     <wp:Toast>
         <wp:Text1>[string]</wp:Text1>
         <wp:Text2>[string]</wp:Text2>
         <wp:Param>[string]</wp:Param>
     </wp:Toast>
   </wp:Notification>;

You use the Param parameter to send parameters to your app :

You can use the Param element to deep link to a specific screen in your app. Here are the allowed formats. Any string used for the following examples must be 256 characters or less.

  • /page1.xaml – Defines the screen to navigate to in the app when the app starts. The string must begin with a "/".
  • /page1.xaml?value1=1234 &value2=9876 – Defines the screen to navigate to when the app starts, along with name/value pairs of info. The string must begin with a "/".
  • ?value1=1234 &value2=9876 – Contains name/value pairs of info passed to the default start screen of the app. The string must begin with a "?".

(taken from here)

pinckerman
  • 4,115
  • 6
  • 33
  • 42
Eran
  • 387,369
  • 54
  • 702
  • 768
  • Hi Eran, just a question, I need the value in in the page I'm navigating from Do I need to add this value into as well? Or do I have some way to get it from OnNavigatedTo method in the desired page? Many thanks – NadavN7 Dec 24 '13 at 18:46
  • 1
    @NadavN7 From the docs, it doesn't look like you have access to the `Text1` value of the notification in `OnNavigatedTo`, so you might have to add it to the `Param`. – Eran Dec 24 '13 at 19:01
  • Yes this is valid for all WP versions AFAIK. – andreszs Jun 20 '16 at 14:42
  • It looks like if you have a WP app compatible WP 8.0 / 8.1 / 10.0, on some end devices under WP 10, the [string] is not taken into account anymore. The onNavigatedTo() method doesn't show it (in your NavigationEventArgs, the URI has no parameters)... Any reason why? – hico Dec 11 '17 at 10:40