简体   繁体   中英

Azure notification hub register template xml not valid

I am using C#, and windows phone 8.1 in Visual Studio 2013 update 5

I am trying to get my windows phone app to register with my Azure notification hub.

If I use the RegisterNativeAsync() method, it registers with no problem.

If I try to use the RegisterTemplateAsync() method, it fails with the error;

The bodyTemplate is not in accepted XML format. The first node of the bodyTemplate should be Tile/Toast, except for raw template.

I am using a template exactly as in the example ie

var customTemplate = string.Format(@"<toast><visual><binding template=""ToastText01"">
           <text id=""1"">$(message)</text></binding></visual></toast>");

In the examples I have seen and the video on MSDN [ link ] no special process is performed on the string.

I believe I need to use templates to get the cross platform notification working, so really need to crack this.

It is frustrating when things done in demos don't work when you try them yourself.

Any ideas on what I need to do to get this to work gratefully received?

I am calling the method like this;

var reg = await hub.RegisterTemplateAsync(e.ChannelUri.ToString(), customTemplate, @"dltemplate", tags);

So,

After more digging, and not initially believing the answer, I can say that this link contains the correct solution. [Link]

Unbelievably, the BOM is preventing the notification hub methods from recognising the xml as valid.

Surely a bug that should have been picked up in testing, or at least referred to in the documentation. (Poor though it is).

Anyway, off to find the next bug/feature.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM