所以我试图让推送通知与Azure和Windows Phone 8一起工作,但我得到一个不受支持的频道uri:'http://s.notify ....'异常。我们得到它与Android和IOS的工作,但我有一个与Windows手机的问题。因此,在Windows Phone上首先进行呼叫就像下面的代码。这给了我一个开放的,看起来像这样:Windows Phone 8推送通知 - 不支持的频道uri
我得到这个代码的方法是使用下面的代码:
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()));
}
之后,我送pushChannel.ChannelUri到服务器以创建我的设备的后端注册。的误差(不支持的信道URI)出现在呼叫:
var registrationDescription = await _hub.CreateOrUpdateRegistrationAsync(registration);
登记来自:
RegistrationDescription registration = new WindowsTemplateRegistrationDescription(request.Handle, request.Template);
手柄被乌里我发送到服务器的请求,并且该模板是XML模板。
现在我不知道出了什么问题,并且因为这个错误而变得有点疯狂。特别是因为代码适用于android和ios,但不适用于wp8。我也尝试过使用PushNotificationChannelManager,但它只是在执行CreatePushNotificationChannelForApplicationAsync调用时崩溃。
在此先感谢
工作很好。非常感谢carlosfigueira !!!!! – kermmeer 2014-09-26 09:32:58