应用商店应用推送通知

应用商店应用推送通知

本文介绍了通过 Azure 服务总线的 Windows 应用商店应用推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向使用 VS 2013 Express 在笔记本电脑中开发的 Windows 应用商店应用发送推送通知.现在已经几天了,但我不明白为什么我收到从令牌提供者获得的令牌是错误的"错误.为此,我使用 Windows Azure 通知总线.我使用 VS Server Explorer 发送测试通知.我也可以在设备注册"选项卡中看到我的笔记本电脑正在注册为设备.我也尝试了 Azure 门户,但同样的错误.但是,当我尝试连接到提供连接字符串的 Service Bus Explorer 2.4.3.0 时,它会引发以下错误.<21:47:14> 异常:远程服务器返回错误:(401) 未经授权.此操作需要管理声明..TrackingId:c0c4fea2-08bc-4def-964c-ec6e690b7551_G45,TimeStamp:10/12/2014 4:17:11 PM.方法 b__7e:重试 10 次中的 2 次.

I'm trying to send a push notification to my Windows Store App developed in my laptop using VS 2013 Express. It's been few days now but I cannot figure out why I get "The Token obtained from the Token Provider is wrong" error. I use Windows Azure Notification Bus for this purpose. I use VS Server Explorer to send test notifications. I can see my laptop is being registered as a device in the Device Registration tab too. I tried the Azure portal as well, but the same error. However, when I try to connect to Service Bus Explorer 2.4.3.0 providing the connection string it throws below error.<21:47:14> Exception: The remote server returned an error: (401) Unauthorized. Manage claim is required for this operation..TrackingId:c0c4fea2-08bc-4def-964c-ec6e690b7551_G45,TimeStamp:10/12/2014 4:17:11 PM. Method b__7e: retry 2 of 10.

仅供参考:我正在逐步关注以下文章.http://azure.microsoft.com/en-us/documentation/articles/notification-hubs-windows-store-dotnet-get-started/

FYI: I'm following below article step by step.http://azure.microsoft.com/en-us/documentation/articles/notification-hubs-windows-store-dotnet-get-started/

请帮帮我.谢谢你.马赫什

Please help me. Thank you.Mahesh

推荐答案

看起来令牌刚刚过期.确保每次应用程序启动时都获得令牌.就您引用的文章而言,这意味着您应该调用方法 InitNotificationsAsync() 来执行此操作.这是该方法:

Looks like token is just expired. Make sure you obtain token each time application starts. In terms of the article you refer it means you should call method InitNotificationsAsync() to do it. Here is that method:

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();
    }

}

这篇关于通过 Azure 服务总线的 Windows 应用商店应用推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 13:16