I have been working on toast notification with the below requirements.
- The application needs to handle all the types of activation Types(foreground, background, protocol)
So I created a sample UWP app. its working for foreground and background. But when I create a toast from the powershell. The notification is not getting activated.
I followed the steps in - https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/send-local-toast-desktop?tabs=msix-sparse
I also verified and can see the GUID in registry.
Repo to the sample app - https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/send-local-toast You need to add a nuget package to make it work - Microsoft.Toolkit.Uwp.Notifications
Powershell script -
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
[Windows.UI.Notifications.ToastNotification, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
$APP_ID = 'DF068783-F662-4A13-8BFC-F8BC1E53F4E6'
$template = @"
<toast activationType="protocol" launch="DF068783-F662-4A13-8BFC-F8BC1E53F4E6WinFormSampleAppActivator" duration="short">
<visual>
<binding template="ToastGeneric">
<image placement="appLogoOverride" src="C:UsersdksilOneDriveDesktopGos.jpg" />
<text><![CDATA[Test]]></text>
<text><![CDATA[some test]]></text>
</binding>
</visual>
<audio src="ms-winsoundevent:Notification.Default" loop="false" />
<actions>
<action activationType="protocol" content="I'm a button" arguments="DF068783-F662-4A13-8BFC-F8BC1E53F4E6" />
</actions>
</toast>
"@
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml($template)
$toast = New-Object Windows.UI.Notifications.ToastNotification $xml
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($APP_ID).Show($toast)
Help Appreciated!!!
question from:https://stackoverflow.com/questions/65835196/windows-toast-notification-com-not-working