loo*_*oop 6 c# azure windows-8 windows-phone-8 windows-8.1
我面临一个奇怪的问题.我使用Windows Phone 8.1 silverlight和Windows通用链接进行Toast通知.我能够在Windows Phone应用程序中获取Toast通知,它在链接中提到的Windows 8.1中几乎相同.但是Toast并没有在Windows 8.1中出现.
步骤: -
1 - >我已经从Package.appxmanifest文件中启用了Toast .
2 - >然后我在上面提到的on_launched事件中的App.Xaml.cs中添加了这段代码
它显示了注册成功,如链接中所述
private async void InitNotificationsAsync()
{
var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
var hub = new NotificationHub("<hub name>", "<connection string with listen access>");
var result = await hub.RegisterNativeAsync(channel.Uri);
// Displays the registration ID so you know it was successful
if (result.RegistrationId != null)
{
var dialog = new MessageDialog("Registration successful: " + result.RegistrationId);
dialog.Commands.Add(new UICommand("OK"));
await dialog.ShowAsync();
}
}
Run Code Online (Sandbox Code Playgroud)
3 - >现在我从后端发送通知(Hub正在处理手机mpns通知的情况).
public static async void SendNotificationAsync()
{
NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString("<connection string with full access>", "<hub name>");
var toast = @"<toast><visual><binding template=""ToastText01""><text id=""1"">Hello from a .NET App!</text></binding></visual></toast>";
await hub.SendWindowsNativeNotificationAsync(toast);
}
Run Code Online (Sandbox Code Playgroud)
问题: - 你们有一个线索,为什么它不能在Windows 8.1中工作或我缺少什么.这是我正在经历的最简单的例子.任何帮助表示赞赏.
编辑: - 这是有趣的事情.
当我试图从azure门户网站发送通知时.从这里的DEBUG选项卡My-NotificationHub我选择WNS吐司然后显示错误.
Error - The token obtained from the token provider is wrong
但是当我试图发送MPNS通知时,没有错误.正如我已经提到的那样,它正在努力WP 8.1 silverlight MPNS toast.
What could be the cause of this error ?
小智 5
如MSDN文档中所述,Toast无法在模拟器上运行:
注意通过Microsoft Visual Studio测试Toast通知代码功能时,必须在Windows x86,x64或Windows运行时计算机上使用本地计算机或远程计算机调试设置.您不能使用Visual Studio Simulator调试功能选项 - 您的代码将在模拟器中编译和运行,但不会出现Toast.
资料来源:http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh868254.aspx
如果我没记错的话,在 Windows 8 上,当我使用模拟器时,Toast 通知不起作用。我必须在计算机上部署 Windows 8 应用程序,而不是模拟器,才能看到 Toast 通知。
| 归档时间: |
|
| 查看次数: |
2347 次 |
| 最近记录: |