Tile notification for windows phone - invalid XML payload - -
i send 2 push notifications toast , tile (just count)
the toast gets received:
<?xml version="1.0" encoding="utf-8"?><wp:notification xmlns:wp="wpnotification"><wp:toast><wp:text1></wp:text1><wp:text2>asdf</wp:text2><wp:param></wp:param></wp:toast></wp:notification>
the tile not:
<?xml version="1.0" encoding="utf-8"?><wp:notification xmlns:wp="wpnotification"><wp:tile><wp:backgroundimage></wp:backgroundimage><wp:count>122</wp:count><wp:title></wp:title><wp:backbackgroundimage></wp:backbackgroundimage><wp:backtitle></wp:backtitle><wp:backcontent></wp:backcontent></wp:tile></wp:notification>
this xml provide , keep getting format errors. there wrong in format?
your tile format should like
string tilemessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<wp:notification xmlns:wp=\"wpnotification\">" + "<wp:tile>" + "<wp:backgroundimage>" + textboxbackgroundimage.text + "</wp:backgroundimage>" + "<wp:count>" + textboxcount.text + "</wp:count>" + "<wp:title>" + textboxtitle.text + "</wp:title>" + "<wp:backbackgroundimage>" + textboxbackbackgroundimage.text + "</wp:backbackgroundimage>" + "<wp:backtitle>" + textboxbacktitle.text + "</wp:backtitle>" + "<wp:backcontent>" + textboxbackcontent.text + "</wp:backcontent>" + "</wp:tile> " + "</wp:notification>";
sending tile notification code.it work me. if query let me know
protected void buttonsendtile_click(object sender, eventargs e) { try { // uri microsoft push notification service returns push client when creating notification channel. // normally, web service listen uri's coming web client , maintain list of uri's send // notifications out to. string subscriptionuri = textboxuri.text.tostring(); httpwebrequest sendnotificationrequest = (httpwebrequest)webrequest.create(subscriptionuri); // create httpwebrequest posts tile notification microsoft push notification service. // http post allowed method send notification. sendnotificationrequest.method = "post"; // optional custom header x-messageid uniquely identifies notification message. // if present, // same value returned in notification response. must string contains uuid. // sendnotificationrequest.headers.add("x-messageid", "<uuid>"); // create tile message. string tilemessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<wp:notification xmlns:wp=\"wpnotification\">" + "<wp:tile>" + "<wp:backgroundimage>" + textboxbackgroundimage.text + "</wp:backgroundimage>" + "<wp:count>" + textboxcount.text + "</wp:count>" + "<wp:title>" + textboxtitle.text + "</wp:title>" + "<wp:backbackgroundimage>" + textboxbackbackgroundimage.text + "</wp:backbackgroundimage>" + "<wp:backtitle>" + textboxbacktitle.text + "</wp:backtitle>" + "<wp:backcontent>" + textboxbackcontent.text + "</wp:backcontent>" + "</wp:tile> " + "</wp:notification>"; // sets notification payload send. byte[] notificationmessage = encoding.default.getbytes(tilemessage); // sets web request content length. sendnotificationrequest.contentlength = notificationmessage.length; sendnotificationrequest.contenttype = "text/xml"; sendnotificationrequest.headers.add("x-windowsphone-target", "token"); sendnotificationrequest.headers.add("x-notificationclass", "1"); using (stream requeststream = sendnotificationrequest.getrequeststream()) { requeststream.write(notificationmessage, 0, notificationmessage.length); } // send notification , response. httpwebresponse response = (httpwebresponse)sendnotificationrequest.getresponse(); string notificationstatus = response.headers["x-notificationstatus"]; string notificationchannelstatus = response.headers["x-subscriptionstatus"]; string deviceconnectionstatus = response.headers["x-deviceconnectionstatus"]; // display response microsoft push notification service. // normally, error handling code here. in real world, because data connections not available, // notifications may need throttled if device cannot reached. textboxresponse.text = notificationstatus + " | " + deviceconnectionstatus + " | " + notificationchannelstatus; } catch (exception ex) { textboxresponse.text = "exception caught sending update: " + ex.tostring(); } }
Comments
Post a Comment