title: Send Push notifications (Toasts) with launch parameters in Windows 8.1
body: <p>I have a WinJS project which has a <strong>BackgroundTask</strong> in <strong>Runtime Component</strong> that triggers when Push Notification is sent (<strong>Raw notifications</strong>) from my own webservice.
  And that Background service creates a local toasts and show it in action notification center.</p>
  
  <pre><code> public static void ShowNotification(int notificationId, string ToastTitle, int messageType, string messageDetails)
      {
          string messageText = String.Empty;
          ToastTemplateType toastTemplate = ToastTemplateType.ToastText04;
          XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);
          XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");
  
          toastTextElements[0].AppendChild(toastXml.CreateTextNode(ToastTitle));//Toast notification title
          toastTextElements[1].AppendChild(toastXml.CreateTextNode(messageText));
          toastTextElements[2].AppendChild(toastXml.CreateTextNode(messageDetails));
  
          var launchAttribute = toastXml.CreateAttribute("launch");
          IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
          ((XmlElement)toastNode).SetAttribute("duration", "short");
          toastNode.Attributes.SetNamedItem(launchAttribute);
  
          //Launch params
          var toastNavigationUriString = messageDetails;
          var toastElement = ((XmlElement)toastXml.SelectSingleNode("/toast"));
          toastElement.SetAttribute("launch", toastNavigationUriString);
  
          ToastNotification toast = new ToastNotification(toastXml);
          toast.Tag = notificationId.ToString();
          toast.ExpirationTime = DateTimeOffset.UtcNow.AddDays(3);
  
          if (true)
          {
              toast.SuppressPopup = false;//to send notification directly to action center without displaying a popup on phone.
          }
  
          ToastNotificationManager.CreateToastNotifier().Show(toast);
      }
  </code></pre>
  
  <p>And I was handling those toasts like this in JS:</p>
  
  <pre><code>WinJS.Application.addEventListener("activated", onActivatedHandler, true);
  
  function onActivatedHandler(args) {
      if (args.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
          messageDetails = args.detail.arguments;
          PhonegapService.setNotificationMessage(messageDetails, function () {
              window.location.href = "index.html";
          });
      }
  }
  </code></pre>
  
  <p><strong>XML</strong> format that is used in this case on my webservice is:</p>
  
  <pre><code>string rawMessage = "&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;" +
              "&lt;root&gt;" +
                  "&lt;Value1&gt;" + "Hello" + "&lt;Value1&gt;" +
                  "&lt;Value2&gt;" + "Raw" + "&lt;Value2&gt;" +
              "&lt;/root&gt;";
  </code></pre>
  
  <p>Now there is slightly change in Push Notifications. I want to send push notifications (<strong>Toasts</strong>) directly from my webservice rather than sending Raw messages.</p>
  
  <p>My questions are:</p>
  
  <ol>
  <li>How to attach <code>launch</code> params and <code>message</code> on my toast notification in web-service similar like we did while creating local toasts.</li>
  <li>When toasts are received how to handle click events and get the useful messages attached with that notification.</li>
  </ol>
  
  <p><strong>XML</strong> in this case would be like this:</p>
  
  <pre><code>string toast1 = "&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt; ";
  
             string toast2 = string.Format(@"&lt;toast&gt;
                         &lt;visual&gt;
                             &lt;binding template=""ToastText04""&gt;
                                 &lt;text id=""1""&gt;{0}&lt;/text&gt;
                                 &lt;launch&gt;&lt;/launch&gt;
                             &lt;/binding&gt;
                         &lt;/visual&gt;
                     &lt;/toast&gt;",message);
             string xml = toast1 + toast2;
  </code></pre>
  
  <p><strong>Update 1</strong></p>
  
  <p>I used the following XML on my web-service. But I'm getting notification in an unusual format than I expected:</p>
  
  <pre><code> string toast1 = "&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt; ";
   string message = "some json";
                  string toast2 = string.Format(@"&lt;toast launch= ""{0}""&gt;
                           &lt;visual version=""1""&gt;
                               &lt;binding template=""ToastText02""&gt;
                                   &lt;text id=""1""&gt;{1}&lt;/text&gt;
                                     &lt;text id=""2""&gt;{2}&lt;/text&gt;
                               &lt;/binding&gt;
                           &lt;/visual&gt;
                       &lt;/toast&gt;", message, "Alert", "Test");
  </code></pre>