I want to send a push notification for Windows phone 8.1, from a desktop windows app.
I found this example:
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.
}
}
}
But I get exception NotFound
An exception of type 'Microsoft.ServiceBus.Messaging.MessagingEntityNotFoundException' occurred in mscorlib.dll but was not handled in user code
Additional information: The remote server returned an error: (404) Not Found. No service is hosted at the specified address..TrackingId:7443c7a8-....c03f7da9_G4,TimeStamp:6/1/2015 9:22:48 PM
Check service at this endpoint.
Most likely an error in the connection string.
Check
Check if you are spelling the NH name correctly or if you have "MinskTransNotificationBeta" actually in the portal.
So mainly this kind of error is Setup/configuration error and it's recommended to review your configuration and change if necessary.
you can check this link to know further about this error.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.