我正在使用此代码从PowerShell脚本发送通知。 PowerShell本身由(持久)Java应用程序启动。
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] > $null
[Windows.UI.Notifications.ToastNotification, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$template = "<toast><visual><binding template=`"ToastText02`"><text id=`"1`">Title</text><text id=`"2`">Test results</text></binding></visual></toast>"
$xml.LoadXml($template)
$toast = New-Object Windows.UI.Notifications.ToastNotification $xml
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("sbt").Show($toast)
它们会在屏幕上弹出,在操作中心可见一段时间,但很快就会消失。由相同代码发送的 XAML 应用程序通知会停留一段时间。是否有办法改变通过脚本发送的通知的行为?
applicationId
吗? - Mathias R. JessenapplicationId
,则它可能会发现通知仍然相关。 - Mathias R. Jessen