【问题标题】:How send push notification from windows app如何从 Windows 应用程序发送推送通知
【发布时间】:2015-06-01 21:29:07
【问题描述】:

我想从桌面 Windows 应用发送 Windows phone 8.1 的推送通知。

我找到了这个例子:

private static async void SendNotificationAsync()
    {
        // Define the notification hub.
        NotificationHubClient hub =
            NotificationHubClient.CreateClientFromConnectionString(
                "Endpoint=sb://...notificationhub-ns.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=9w3Mo....NNcDRI=", "MinskTransNotificationBeta");

        // Create an array of breaking news categories.
        var categories = new string[] { "World", "Politics", "Business", 
    "Technology", "Science", "Sports"};

        foreach (var category in categories)
        {
            try
            {
                // Define a Windows Store toast.
                //var wnsToast = "<toast><visual><binding template=\"ToastText01\">"
                //  + "<text id=\"1\">Breaking " + category + " News!"
                //  + "</text></binding></visual></toast>";
                //await hub.SendWindowsNativeNotificationAsync(wnsToast, category);

                // Define a Windows Phone toast.
                var mpnsToast =
                    "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                    "<wp:Notification xmlns:wp=\"WPNotification\">" +
                        "<wp:Toast>" +
                            "<wp:Text1>Breaking " + category + " News!</wp:Text1>" +
                        "</wp:Toast> " +
                    "</wp:Notification>";
                await hub.SendMpnsNativeNotificationAsync(mpnsToast, category);


            }
            catch (ArgumentException)
            {
                // An exception is raised when the notification hub hasn't been 
                // registered for the iOS, Windows Store, or Windows Phone platform. 
            }
        }
    }

但我得到异常 NotFound

类型异常 'Microsoft.ServiceBus.Messaging.MessagingEntityNotFoundException' 发生在 mscorlib.dll 中,但未在用户代码中处理

附加信息:远程服务器返回错误:(404) Not 成立。没有服务托管在指定位置 地址..TrackingId:7443c7a8-..c03f7da9_G4,TimeStamp:6/1/2015 晚上 9 点 22 分 48 秒

【问题讨论】:

    标签: c# azure windows-phone-8 push-notification windows-phone-8.1


    【解决方案1】:

    检查此端点的服务。

    很可能是连接字符串中的错误。

    【讨论】:

      【解决方案2】:

      检查

      • 从 Azure 门户启用未经身份验证的推送通知。
      • 检查您的连接字符串并确保您使用的是 FullSharedAccesKey。(您的 SAS 名称必须与连接字符串中的字符串匹配)
      • 您有互联网连接。

      【讨论】:

        【解决方案3】:

        检查您是否正确拼写了 NH 名称,或者您在门户中是否确实有“MinskTransNotificationBeta”。

        所以这种错误主要是设置/配置错误,建议检查您的配置并在必要时进行更改。

        您可以查看此link 以进一步了解此错误。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2012-10-24
          • 2019-09-11
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-07-06
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多