Quantcast
Channel: Service Bus forum
Viewing all articles
Browse latest Browse all 1916

Unable to register channel uri

$
0
0

(I submitted this to StackOverflow a few days ago with no results http://stackoverflow.com/questions/20526705/invaliddatacontractexception-using-azure-notification-hub)

I'm following this article on how to notify users using Notification Hub push notifications (http://www.windowsazure.com/en-us/manage/services/notification-hubs/notify-users-aspnet/) and what doesn't work is trying to create a new Window registration using:

registration = await hubClient.CreateWindowsNativeRegistrationAsync(reg.ChannelUri, new string [] { reg.InstallationID, user._id });

Everytime it gets to this bit of code it fails with an InvalidDataContractExcepton. I realise this is to do with serialisation but the serialisation is happening behind the scenes in the Microsoft.ServiceBus where it's failing. I'm passing in valid uri's as strings and everything compiles fine. After keeping on experiencing this I decided to hardcode the uri as a string, that too failed with the following:

"Unsupported channel uri: http://test.com"

Still no idea how and why this happens. Passing in a uri doesn't compile.

I've inspected the request using Fiddler and can confirm the request is never sent.

Full code:

public async Task<bool> 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<string>() { 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;
    }
  }
}



Viewing all articles
Browse latest Browse all 1916

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>