php - How to set push notification receive message target page in windows phone? -


i need set push notification receive message target page in windows phone. can send , receive toast push notifications, when click received toast message goes main page. when click toast message need app open in target page. please let me know why facing in issue , wrong in code.

my code given below:

c# receive target page:

 void pushchannel_shelltoastnotificationreceived(object sender, notificationeventargs e)     {         stringbuilder message = new stringbuilder();         string relativeuri = string.empty;          message.appendformat("received toast {0}:\n", datetime.now.toshorttimestring());          // parse out information part of message.         foreach (string key in e.collection.keys)         {             message.appendformat("{0}: {1}\n", key, e.collection[key]);              if (string.compare(                 key,                 "wp:param",                 system.globalization.cultureinfo.invariantculture,                 system.globalization.compareoptions.ignorecase) == 0)             {                 relativeuri = e.collection[key];              }         }          // display dialog of fields in toast.         dispatcher.begininvoke(() => messagebox.show(message.tostring()));      }     protected override void onnavigatedto(system.windows.navigation.navigationeventargs e)     {         base.onnavigatedto(e);          //  if navigated page         // mainpage, defaulttitle parameter "frommain".  if navigated here         // when secondary tile tapped, parameter "fromtile".         textblockfrom.text = "navigated here " + this.navigationcontext.querystring["navigatedfrom"];      } 

i using php code sending push notifications:

  <?php    final class windowsphonepushdelay   {     const immediate=0;     private function __construct(){}  }   class windowsphonepushnotification  {   private $notif_url = '';    function windowsphonepushnotification($notif_url)   {      $this->notif_url = $notif_url;   }   public function push($target,$message,$notif_url)   {     // create toast message    $toastmessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" .             "<wp:notification xmlns:wp=\"wpnotification\">" .                "<wp:toast>" .                     "<wp:text1>" . "sendtoast" . "</wp:text1>" .                     "<wp:text2>" . $message . "</wp:text2>" .                     "<wp:param>/receive.xaml?navigatedfrom=toast notification</wp:param>" .                     "</wp:toast> " .             "</wp:notification>";    // create request send      $r = curl_init();      curl_setopt($r, curlopt_url,$notif_url);      curl_setopt($r, curlopt_returntransfer, 1);      curl_setopt($r, curlopt_post, true);      curl_setopt($r, curlopt_header, true);     // add headers      $httpheaders=array('content-type: text/xml; charset=utf-8', 'x-windowsphone-target: toast',                 'accept: application/*', 'x-notificationclass: 2','content-length:'.strlen($toastmessage));   curl_setopt($r, curlopt_httpheader, $httpheaders);    // add message   curl_setopt($r, curlopt_postfields, $toastmessage);    // execute request   $output = curl_exec($r);   curl_close($r);     } }  ?> 

i need output in image below

enter image description here

the wp:param that's part of toast notification's payload should uri. therefore should encoded one. in example you're providing there's space in payload, might causing problems. try formatting this?

  "<wp:param>/receive.xaml?navigatedfrom=toast%20notification</wp:param>" . 

also make sure receive.xaml indeed in root of package.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -