Azure通知中心UWP、UWP Toast通知不启动应用程序

标签 azure push-notification uwp

我正在按照本教程使用 UWP 应用程序的通知中心:Getting started with Notification Hubs for Windows Universal Platform Apps .

如果我测试发送 Windows 8 通知,例如:

<?xml version="1.0" encoding="utf-8"?>
<toast>
<visual><binding template="ToastText01">
<text id="1">Test message</text>
</binding>
</visual>
</toast>

它有效,如果我单击通知,它会通过 OnLaunched() 方法打开应用程序。但如果我发送 UWP 特定通知,例如:

<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
  <text>Microsoft Company Store</text>
  <text>New Halo game is back in stock!</text>
</binding>
</visual>
<actions>
<action activationType="foreground" content="See more details" arguments="details"/>
<action activationType="background" content="Remind me later" arguments="later"/>
</actions>
</toast>

toast 可以工作,但如果我点击它,它会打开应用程序,并且 OnLaunched() 从未调用,因此应用程序卡在启动屏幕上。

预先感谢您的帮助,

问候

最佳答案

您需要在 app.xaml.cs 中实现 OnActivated

 protected override void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);
        }

参见https://blogs.msdn.microsoft.com/tiles_and_toasts/2015/07/08/quickstart-sending-a-local-toast-notification-and-handling-activations-from-it-windows-10/

关于Azure通知中心UWP、UWP Toast通知不启动应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41715738/

相关文章:

android - 如何在华为上显示应用图标徽章编号

ios - iOS自定义声音通知位置

azure - 为通过 Azure 函数输出绑定(bind)添加到 Azure 队列的消息设置 VisibilityTimeout

asp.net - 发布到 Azure 网站后无法加载文件或程序集 System.Web.Http.WebHost

ios - didReceiveRemoteNotification 和模态视图

c# - 如何在 UWP 等 WPF 应用程序中使用连接动画

uwp - 我们可以将 UWP BackgroundTask(WindowsRuntimeComponent) 作为 Windows 服务托管吗?

popup - 如何在 UWP 中弹出消息?

azure - 如何参数化azure逻辑应用标准项目的workflow.json和connections.json文件中的值

azure - 如何使用循环分配系统管理身份对 Key Vault 的访问权限?