按照“通知中心入门”逐行遍历并验证我已正确完成所有操作。从我能看到的。但是,我没有收到 Windows 应用商店应用程序的通知消息。
代码运行,没有错误。我可以看到注册出现在 NH 仪表板上,因为图表显示了操作。
但什么也没有发生。
我该如何解决这个问题?
//register yourself with WNS and tell it you are ready to receive Push Notifications
var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
//connect to service bus
var cn = ConnectionString.CreateUsingSharedAccessKey(new Uri("sb://<namespace>.servicebus.windows.net"),
"<sharedaccesskeyname>", "<sharedaccesskey>");
//connect to Notification Hub
NotificationHub hub = new NotificationHub("<hub name>", cn);
//Send the channel.Uri from WNS to Notification Hubs
await hub.RegisterNativeAsync(channel.Uri);
然后后端代码是执行此操作的简单控制台应用程序;
var client = NotificationHubClient.CreateClientFromConnectionString(
"Endpoint=sb://<namespace>.servicebus.windows.net/;SharedAccessKeyName=<sharedkeyname>;SharedAccessKey=<sharedaccesskey>",
"<hub name>");
//send a message through NH
await client.SendWindowsNativeNotificationAsync(String.Format("<toast><visual><binding template=\"ToastText01\"><text id=\"1\">{0}</text></binding></visual></toast>",
"Hello!"));