go-toast icon indicating copy to clipboard operation
go-toast copied to clipboard

Notifications do not appear in Windows 10 Entreprise

Open younes199511 opened this issue 3 years ago • 13 comments

Hello,

I'm trying to use your package in my custom application to display notifications. It is working fine on Windows 10 Professionnel but nothing appears when i run my application on Windows 10 Entreprise (The app runs without errors but does not display the notification)

Do you have any idea why it is not working on Windows 10 Entreprise ? Or if there is any dependencies that should be installed on windows to make it work.

Thank you

Capture

younes199511 avatar May 21 '22 12:05 younes199511

https://docs.microsoft.com/en-us/windows/whats-new/ltsc/ https://techcommunity.microsoft.com/t5/windows-it-pro-blog/ltsc-what-is-it-and-when-should-it-be-used/ba-p/293181

I guess the Windows Runtime API is different

electricbubble avatar May 21 '22 14:05 electricbubble

Thank you for your quick answer.

Yes maybe the Windows Runtime API is different but i think it's more a dependency issue.

For example this package https://github.com/hallazzang/go-windows-programming/tree/master/example/gui/notifyicon is working fine with both windows environments which means that the APIs are the same i think.

The advantage of your package for me is that it's working correctly even if i run my application as a windows service (normally it should not because windows services can not interact with windows desktop) which is not the case for all other packages i tested even in other programming languages.

I will continue my investigation.

Thank you again.

younes199511 avatar May 21 '22 15:05 younes199511

https://github.com/hallazzang/go-windows-programming/tree/master/example/gui/notifyicon

This is a different implementation.


Can you try fyne-io/fyne?

If it can work, I think I can try to fix it.


// https://github.com/fyne-io/fyne/blob/7229e889d49c81a83b0b7e09400837f67f6ddad5/test/notification_test.go#L12-L20
func TestAssertNotificationSent(t *testing.T) {
	n := fyne.NewNotification("Test Title", "Some content")
	myApp := fyne.CurrentApp()


	test.AssertNotificationSent(t, n, func() {
		fyne.CurrentApp().SendNotification(n)
	})
	assert.Equal(t, myApp, fyne.CurrentApp())
}

electricbubble avatar May 21 '22 15:05 electricbubble

I tried fyne-io/fyne and it is working fine in both windows environments.

younes199511 avatar May 21 '22 19:05 younes199511

Can you help me test it on Windows 10 Enterprise?

  1. Copy the following code and save the file as toast.ps1
[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 = 'test_AppID'

$template = @"
<toast activationType="protocol"  duration="short">
    <visual>
        <binding template="ToastGeneric">
            <text>test_title</text>
            <text>test_message</text>
        </binding>
    </visual>
    <audio silent="true" />
</toast>
"@

$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml($template)
$go_toast = New-Object Windows.UI.Notifications.ToastNotification $xml
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($APP_ID).Show($go_toast)
  1. Execute this command in cmd.exe (please change the file path)
PowerShell -ExecutionPolicy Bypass "(Get-Content -Encoding UTF8 -Path D:\issues2\toast.ps1 -Raw) | Invoke-Expression;"

electricbubble avatar May 22 '22 16:05 electricbubble

I tested this script in Windows Entreprise environment and it's not working. I got no error when executing the script but the notification does not appear.

younes199511 avatar May 22 '22 19:05 younes199511

Please delete this line and try again

[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 = 'test_AppID'

$template = @"
<toast activationType="protocol"  duration="short">
    <visual>
        <binding template="ToastGeneric">
            <text>test_title</text>
            <text>test_message</text>
        </binding>
    </visual>
--    <audio silent="true" />
</toast>
"@

$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml($template)
$go_toast = New-Object Windows.UI.Notifications.ToastNotification $xml
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($APP_ID).Show($go_toast)

electricbubble avatar May 23 '22 01:05 electricbubble

I retested without this line and it still not working. I dont know if it can help but this PowerShell module https://github.com/Windos/BurntToast works fine in both environments

younes199511 avatar May 23 '22 07:05 younes199511

I've followed github.com/Windos/BurntToast, but I can't understand how it works


Please delete these lines and try again

[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 = 'test_AppID'

$template = @"
<toast activationType="protocol"  duration="short">
    <visual>
        <binding template="ToastGeneric">
            <text>test_title</text>
            <text>test_message</text>
        </binding>
    </visual>
--  <audio silent="true" />
</toast>
"@

$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml($template)
$go_toast = New-Object Windows.UI.Notifications.ToastNotification $xml
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($APP_ID).Show($go_toast)

electricbubble avatar May 23 '22 14:05 electricbubble

It still not working but this time it returns the below error (I'm sorry the error is written in french but to resume it can not find Windows.Data.Xml.Dom.XmlDocument ) :

image

younes199511 avatar May 23 '22 14:05 younes199511

Sorry, I'm still trying to figure out the differences with fyne-io/fyne

Please try again, if it still doesn't work, I'm sorry I may not understand how it works correctly

[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 = 'test_AppID'

$template = @"
<toast activationType="protocol"  duration="short">
    <visual>
        <binding template="ToastGeneric">
            <text>test_title</text>
            <text>test_message</text>
        </binding>
    </visual>
    <audio silent="true" />
</toast>
"@

$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml($template)
$go_toast = New-Object Windows.UI.Notifications.ToastNotification $xml
--[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($APP_ID).Show($go_toast)
++[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("$APP_ID").Show($go_toast);

electricbubble avatar May 23 '22 14:05 electricbubble

It still not working.

Thank you for your investigation. i think i will use github.com/Windos/BurntToast for my application.

Thank you again

younes199511 avatar May 23 '22 14:05 younes199511

Very sorry, I will keep an eye on github.com/Windos/BurntToast and try to fix it

electricbubble avatar May 23 '22 14:05 electricbubble