0
votes

So I'm trying to get the push notifications working with Azure and windows phone 8 but I get a Unsupported channel uri: 'http://s.notify....' exception. We got it working with android and ios but I have a problem with windows phone. So on the windows phone where doing first the call's like the code below. This gives me a Uri that looks like this:

http://s.notify.live.net/u/1/db3/HmQAAABvGpd1XkjaC-XkYBpLYRrzC_DuH5ahcYzhdl8bT38ZJwNhI7_RGjG2ggirG0P1LJ2e6QAYm0uslRnGqcaImzdq/cHYtZGV2ZWxvcC1tZXNzYWdlcw/7A7WUjse3k2tlLMokVXD6g/rJ4ipeALhkNuxmeeJAAdsrrKRhY

The way I got this code is with this code:

HttpNotificationChannel pushChannel;

        // Try to find the push channel.
        pushChannel = HttpNotificationChannel.Find(App.HubName);

        // If the channel was not found, then create a new connection to the push service.
        if (pushChannel == null)
        {
            pushChannel = new HttpNotificationChannel(App.HubName, App.ServiceName);

            // Register for all the events before attempting to open the channel.
            pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
            pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

            // Register for this notification only if you need to receive the notifications while your application is running.
            pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);

            pushChannel.Open();

            // Bind this new channel for Tile events.
            pushChannel.BindToShellToast();
        }
        else
        {
            // The channel was already open, so just register for all the events.
            pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
            pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

            // Register for this notification only if you need to receive the notifications while your application is running.
            pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);

            // Display the URI for testing purposes. Normally, the URI would be passed back to your web service at this point.
            System.Diagnostics.Debug.WriteLine(pushChannel.ChannelUri.ToString());
            MessageBox.Show(String.Format("Channel Uri is {0}", pushChannel.ChannelUri.ToString()));
        }

After that I send the pushChannel.ChannelUri to the server to create a backend registration of my device. The error (Unsupported channel uri) appears at the call:

var registrationDescription = await _hub.CreateOrUpdateRegistrationAsync(registration);

The registration comes from:

RegistrationDescription registration = new WindowsTemplateRegistrationDescription(request.Handle, request.Template);

The Handle is the request Uri I send to the server and the template is the xml template.

Now I don't know whats going wrong and am becoming a little bit crazy because of this error. Especially since the code works for android and ios but not for the wp8. I also tried with the PushNotificationChannelManager but it just crashes when it's doing the CreatePushNotificationChannelForApplicationAsync call.

Thanks in advance

2

2 Answers

0
votes

Until WinPhone 8.0, the push notifications for that platform was done by the "MPNS" (Microsoft Push Notification System). On Windows Phone 8.1 there are now two options: if you're building the new universal or "store" version, you'd use the same version that is used for regular Windows Store apps (WNS - Windows Notification System). What you're doing is mixing up the two versions of the notification in the same code. When you create a notification channel using the HttpPushNotification class (from Microsoft.Phone.Notification namespace), you're using the MPNS registration. If this is the case, then you should not use the WindowsTemplateRegistrationDescription class; instead, use the MpnsTemplateRegistrationDescription one.

-1
votes

In case you are running your code in the phone simulator: The simulator does not support recieving Push messages - You will have to use a "real" phone.