我想从桌面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
类型的例外 &#39; Microsoft.ServiceBus.Messaging.MessagingEntityNotFoundException&#39; 发生在mscorlib.dll中但未在用户代码中处理
其他信息:远程服务器返回错误:(404)不是 发现。指定的服务未托管 address..TrackingId:7443c7a8 -.... c03f7da9_G4,时间戳:2015年6月1日 晚上9:22:48
答案 0 :(得分:0)
检查此端点的服务。
很可能是连接字符串中的错误。
答案 1 :(得分:0)
检查
答案 2 :(得分:0)
检查门户中是否正确拼写了NH名称,或者门户中是否确实有“ MinskTransNotificationBeta”。
所以这种错误主要是安装/配置错误,建议您检查配置并在必要时进行更改。
您可以检查此link以进一步了解此错误。