我的 uwp 应用程序从 php 服务器接收 toast 通知。它有两个操作按钮“查看”和“关闭”。当应用程序当前处于激活状态时,这些按钮可以正常工作。(查看按钮单击重定向到新页面,而关闭按钮单击将不会执行任何操作。)。但是当应用程序处于关闭状态时 - 当用户点击通知的关闭按钮时,应用程序的启动图标就会出现。我怎样才能阻止这个?当用户单击 Dismiss 按钮时,我想关闭通知。
$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();
}
}
}