我试图用VS 2013 Express向我的笔记本电脑中的Windows应用程序发送推送通知。现在已经过了几天了,但我不明白为什么我会得到“从令牌提供程序获得的令牌是错误的”错误。为此,我使用Windows通知总线。我使用VS服务器资源管理器发送测试通知。我可以看到我的笔记本电脑也被注册为设备注册选项卡。我也尝试过Azure门户,但也有同样的错误。但是,当我试图连接到Service资源管理器2.4.3.0提供它在错误下面抛出的连接字符串时。<21:47:14>异常:远程服务器返回一个错误:(401)未经授权。此operation..TrackingId:c0c4fea2-08bc-4def-964c-ec6e690b7551_G45,时间戳:10/12/2014 4:17:11 PM需要管理索赔方法b__7e:重试10例中的2例。
FYI:我正在一步一步地关注下面的文章。http://azure.microsoft.com/en-us/documentation/articles/notification-hubs-windows-store-dotnet-get-started/
请帮帮我。谢谢。马赫什
发布于 2014-10-13 22:26:15
看来令牌已经过期了。确保每次启动应用程序时都获得令牌。在本文中,它意味着您应该调用方法InitNotificationsAsync()来完成它。这是一种方法:
private async void InitNotificationsAsync()
{
var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
var hub = new NotificationHub("<hub name>", "<connection string with listen access>");
var result = await hub.RegisterNativeAsync(channel.Uri);
// Displays the registration ID so you know it was successful
if (result.RegistrationId != null)
{
var dialog = new MessageDialog("Registration successful: " + result.RegistrationId);
dialog.Commands.Add(new UICommand("OK"));
await dialog.ShowAsync();
}
}https://stackoverflow.com/questions/26332391
复制相似问题