Note that there are some explanatory texts on larger screens.

plurals
  1. POInvalidDataContractException using Azure Notification Hub
    text
    copied!<p>I'm pretty much copying this article about using the Windows Azure Notification Hub to send push notifications: <a href="http://www.windowsazure.com/en-us/manage/services/notification-hubs/notify-users-aspnet/" rel="nofollow">http://www.windowsazure.com/en-us/manage/services/notification-hubs/notify-users-aspnet/</a></p> <p>Unfortunately, I'm running into an <strong>InvalidDataContractException occurring in Microsoft.ServiceBus</strong> when I try to use the <strong>CreateWindowsNativeRegistrationAsync</strong> method. I can't see any difference in my code from the example and I'm not doing an serialisation. (about half way down the page):</p> <p><strong>UPDATE:</strong> Putting the same code in a console app with "<a href="http://test.com" rel="nofollow">http://test.com</a>" as the channelURI causes an exception and the following error: "Unsupported channel uri: <a href="http://test.com" rel="nofollow">http://test.com</a>"</p> <pre><code>public async Task&lt;bool&gt; NotificationRegistration(User user, NotificationRegistration reg) { var regs = await hubClient.GetRegistrationsByTagAsync(reg.InstallationID, 100); bool updated = false; bool firstRegistration = true; RegistrationDescription registration = null; foreach (var regDescription in regs) { if (firstRegistration) { regDescription.Tags = new HashSet&lt;string&gt;() { reg.InstallationID, user._id }; // We need to handle each platform separately. switch (reg.Platform) { case "WP": var winReg = regDescription as WindowsRegistrationDescription; winReg.ChannelUri = new Uri(reg.ChannelUri); registration = await hubClient.UpdateRegistrationAsync(winReg); break; } updated = true; firstRegistration = false; } else { // We shouldn't have any extra registrations; delete if we do. await hubClient.DeleteRegistrationAsync(regDescription); } } // Create a new registration. if (!updated) { switch (reg.Platform) { case "WP": //always fails here registration = await hubClient.CreateWindowsNativeRegistrationAsync(reg.ChannelUri, new string [] { reg.InstallationID, user._id }); break; } } } </code></pre> <p>Any guidance as to where I'm going wrong would be greatly appreciated....</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload