我的uwp应用程序从php服务器接收烤面包通知。它具有两个操作按钮“查看”和“关闭”。当应用当前处于激活状态时,这些按钮可以正常工作。(单击查看按钮将重定向到新页面,单击取消按钮将不会执行任何操作。)但是,当应用程序处于关闭状态时-当用户单击通知的“关闭”按钮时,应用程序的启动图标即将到来。我该如何阻止呢?我想在用户单击“关闭”按钮时关闭该通知。
$toastMessage= '<toast launch="app-defined-string">'.
'<visual>'.
'<binding template="ToastGeneric">'.
'<text>'.$title.'</text>'.
'<text>'.$subtitle.'</text>'.
'</binding>'.
'</visual>'.
'<audio src="ms-winsoundevent:Notification.SMS" />'.
'<actions>'.
'<action activationType="foreground" content="View" arguments="viewdetails"/>'.
'<action content="Dismiss" arguments="later"/>'.
'</actions>'.
'</toast>';
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.ToastNotification)
{
var toastArgs = args as ToastNotificationActivatedEventArgs;
var arguments = toastArgs.Argument;
if (arguments == "viewdetails" || arguments== "app-defined-string")
{
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
rootFrame = new Frame();
Window.Current.Content = rootFrame;
}
rootFrame.Navigate(typeof(PushNotificationPage));
Window.Current.Activate();
}
}
}
敬酒内容文档描述了如何在“贪睡/解雇”部分添加解雇按钮:https : //docs.microsoft.com/zh-cn/windows/uwp/design/shell/tiles-and-notifications/adaptive-interactive-吐司#snoozedismiss
<action activationType="system" arguments="dismiss" content=""/>
基本上,将activationType设置为system,将参数设置为dismiss。将内容设置为空字符串,用于解雇的本地化文本将被自动使用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句