我正在尝试做一个非常简单的演示,以展示如何使用后台任务和烤面包通知UWP。我有一个简单的任务,在网络连接改变时触发,他的工作是显示一个简单的通知。它当然在操作系统中注册,在清单中选择并且此任务运行良好。应用程序无法从ToastNotification操作正确运行
我创建了一个软件包,并在我的笔记本电脑上安装了该应用程序,以便在应用程序未启动时运行它。任务也适用。
唯一的问题是,当我点击通知中的“运行应用程序”按钮时,我想启动在前台运行的应用程序。它启动的应用程序,但我可以看到的唯一的事情就是我的应用程序的启动画面,没有其他事情发生。我看到了这个通知的教程MSDN,我的XML几乎是一样的。
我的XML通知的内容:
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>Test notification</text>
<text>This is a simple toast notification</text>
<image placement="AppLogoOverride" src="../Assets/icon.png"/>
</binding>
</visual>
<actions>
<action activationType="foreground" content="Run App" arguments="check" />
</actions>
<audio src="ms-winsoundevent:Notification.SMS" />
</toast>
UPDATE
在App.xaml.cs唯一的修改部分:
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.ToastNotification)
{
var toastArgs = (ToastNotificationActivatedEventArgs)args;
ToastArg = toastArgs.Argument;
}
}
你可以发布你的App.xaml.cs吗? – thang2410199
当然,我添加了App.xaml.cs的唯一修改部分,其余部分仅仅是标准的“启动”应用程序代码。但我没有这个代码尝试过,结果是一样的。 –