【发布时间】: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