无法使用Azure通知中心发送推送通知

时间:2014-11-19 14:02:36

标签: azure windows-phone-8 push-notification azure-mobile-services

我正在尝试创建一个通知总线,将推送通知发送到我的Windows Phone App。

我引用了link并遵循了所有步骤。

我的应用程序正在注册httpchannel

var channel = HttpNotificationChannel.Find("MyPushChannel");
        if (channel == null)
        {
            channel = new HttpNotificationChannel("MyPushChannel");
            channel.Open();
            channel.BindToShellToast();
        }

        channel.ChannelUriUpdated += async (o, args) =>
        {
            var hub = new NotificationHub("xyz", "Endpoint=sb://xyz-ns.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=DWNOTQgqiKsDsTpXx4kUyeBPLsdSlFEP2YZIMW1dMEU=");
            await hub.RegisterNativeAsync(args.ChannelUri.ToString());
        };

控制台应用程序

private static async void SendNotificationAsync()
    {
        var hub = NotificationHubClient
            .CreateClientFromConnectionString("Endpoint=sb://xyz-ns.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=6P1isg5Uv97hJxRqbvJ11yJL+UV49RTSZNALJAoVCzI=",
            "xyz");
        const string toast = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                             "<wp:Notification xmlns:wp=\"WPNotification\">" +
                             "<wp:Toast>" +
                             "<wp:Text1>Hello from a .NET App!</wp:Text1>" +
                             "</wp:Toast> " +
                             "</wp:Notification>";
        await hub.SendMpnsNativeNotificationAsync(toast);
    }

我甚至在门户网站中启用了未经授权的通知。但是,当我运行控制台应用程序时,我无法收到通知。

我的控制台应用程序看起来像这样

static void Main()
    {
        SendNotificationAsync();
    }

有人可以帮助我解决这个问题吗?

0 个答案:

没有答案