1
votes

I need to configure Azure Notification Hub to send templated notifications for different mobile platforms. For Windows Phone 8 it should be a toast with ability to navigate to a specific page with query parameters. These parameters must be configurable as well as toast header and message. Here is the template:

 "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
 "<wp:Notification xmlns:wp=\"WPNotification\">" +
     "<wp:Toast>" +
         "<wp:Text1>$(caption)</wp:Text1>" +
         "<wp:Text2>$(content)</wp:Text2>" +
         "<wp:Param>/Views/TargetPage.xaml?p1=$(v1)&amp;p2=$(v2)</wp:Param>"+
     "</wp:Toast> " +
 "</wp:Notification>"

Now about the problem. When sending test notifications, the header and content of toast are as expected, but payload is not updated for some reason. As a result, I receive two query parameters p1: "$(v1)", p2: "$(v2)". It seems to be some payload encoding problem or the notification hub does not take payload into account when applying template at all, but both these ideas sound wrong. Have you faced a similar problem? Just a remark, in the case of wrong parameter names the values are replaces with "", so it`s not my case.

1
You should include your server code in the question. It's likely the problem is there (you are probably not replacing the v1 & v2 parameters of the template with the real values). - Eran
@Eran Server part is fully controlled by Azure Notification Hub, I guess MS won't let me debug their code :) - Alex Yurov

1 Answers

1
votes

Unfortunately you cannot intermix property in the template like you did. When you use concatenation you have to explicitly add an expression evaluation operator ' {}'.

In your case:

"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
 "<wp:Notification xmlns:wp=\"WPNotification\">" +
     "<wp:Toast>" +
         "<wp:Text1>$(caption)</wp:Text1>" +
         "<wp:Text2>$(content)</wp:Text2>" +
         "<wp:Param>{'/Views/TargetPage.xaml?p1=' + $(v1) + '&amp;p2=' + $(v2)}</wp:Param>"+
     "</wp:Toast> " +
 "</wp:Notification>"

MSDN article: http://msdn.microsoft.com/en-us/library/dn530748.aspx